Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7cfbff7482 | |||
| 2c7c18fd24 | |||
| 5ddbb25237 | |||
| 9ba60d0d5c | |||
| 4f0ec785f6 | |||
| 02b50458b0 | |||
| 0a556fe450 | |||
| f2f167c95d | |||
| 8b45ff7a18 | |||
| 4c665b24d9 | |||
| 381d492a8f | |||
| e250c83c21 | |||
| e2e326d15e | |||
| 4abca85474 | |||
| 2c78d862a3 |
+135
-2
@@ -13,7 +13,6 @@ notifications:
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- 5.21
|
||||
# enable building tags
|
||||
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
|
||||
|
||||
@@ -37,6 +36,10 @@ env:
|
||||
- ENABLE_NODE_BINDINGS=On
|
||||
- NODE="10"
|
||||
|
||||
stages:
|
||||
- core
|
||||
- optional
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
@@ -44,12 +47,14 @@ matrix:
|
||||
include:
|
||||
|
||||
# Debug Builds
|
||||
- os: linux
|
||||
- stage: core
|
||||
os: linux
|
||||
compiler: "format-taginfo-docs"
|
||||
env: NODE=10
|
||||
sudo: false
|
||||
before_install:
|
||||
install:
|
||||
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
|
||||
- source $NVM_DIR/nvm.sh
|
||||
- nvm install $NODE
|
||||
- nvm use $NODE
|
||||
@@ -276,7 +281,135 @@ matrix:
|
||||
after_success:
|
||||
- ./scripts/travis/publish.sh
|
||||
|
||||
- os: osx
|
||||
stage: optional
|
||||
osx_image: xcode9.2
|
||||
compiler: "mason-osx-release-node-latest"
|
||||
# we use the xcode provides clang and don't install our own
|
||||
env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="node"
|
||||
after_success:
|
||||
- ./scripts/travis/publish.sh
|
||||
|
||||
- os: linux
|
||||
sudo: false
|
||||
compiler: "node-latest-mason-linux-release"
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['libstdc++-4.9-dev']
|
||||
env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node"
|
||||
install:
|
||||
- pushd ${OSRM_BUILD_DIR}
|
||||
- |
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DENABLE_MASON=${ENABLE_MASON:-OFF} \
|
||||
-DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
|
||||
-DENABLE_CCACHE=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
|
||||
-DENABLE_GLIBC_WORKAROUND=ON
|
||||
- make --jobs=${JOBS}
|
||||
- popd
|
||||
script:
|
||||
- npm run nodejs-tests
|
||||
after_success:
|
||||
- ./scripts/travis/publish.sh
|
||||
|
||||
- os: linux
|
||||
sudo: false
|
||||
compiler: "node-latest-mason-linux-debug"
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['libstdc++-4.9-dev']
|
||||
env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node"
|
||||
install:
|
||||
- pushd ${OSRM_BUILD_DIR}
|
||||
- |
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DENABLE_MASON=${ENABLE_MASON:-OFF} \
|
||||
-DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
|
||||
-DENABLE_CCACHE=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
|
||||
-DENABLE_GLIBC_WORKAROUND=ON
|
||||
- make --jobs=${JOBS}
|
||||
- popd
|
||||
script:
|
||||
- npm run nodejs-tests
|
||||
after_success:
|
||||
- ./scripts/travis/publish.sh
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.2
|
||||
compiler: "mason-osx-release-node-lts"
|
||||
# we use the xcode provides clang and don't install our own
|
||||
env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="--lts"
|
||||
after_success:
|
||||
- ./scripts/travis/publish.sh
|
||||
|
||||
- os: linux
|
||||
sudo: false
|
||||
compiler: "node-lts-mason-linux-release"
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['libstdc++-4.9-dev']
|
||||
env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts"
|
||||
install:
|
||||
- pushd ${OSRM_BUILD_DIR}
|
||||
- |
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DENABLE_MASON=${ENABLE_MASON:-OFF} \
|
||||
-DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
|
||||
-DENABLE_CCACHE=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
|
||||
-DENABLE_GLIBC_WORKAROUND=ON
|
||||
- make --jobs=${JOBS}
|
||||
- popd
|
||||
script:
|
||||
- npm run nodejs-tests
|
||||
after_success:
|
||||
- ./scripts/travis/publish.sh
|
||||
|
||||
- os: linux
|
||||
sudo: false
|
||||
compiler: "node-lts-mason-linux-debug"
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['libstdc++-4.9-dev']
|
||||
env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts"
|
||||
install:
|
||||
- pushd ${OSRM_BUILD_DIR}
|
||||
- |
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DENABLE_MASON=${ENABLE_MASON:-OFF} \
|
||||
-DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
|
||||
-DENABLE_CCACHE=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
|
||||
-DENABLE_GLIBC_WORKAROUND=ON
|
||||
- make --jobs=${JOBS}
|
||||
- popd
|
||||
script:
|
||||
- npm run nodejs-tests
|
||||
after_success:
|
||||
- ./scripts/travis/publish.sh
|
||||
|
||||
allow_failures:
|
||||
- compiler: "mason-osx-release-node-latest"
|
||||
env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="node"
|
||||
- compiler: "node-latest-mason-linux-release"
|
||||
env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node"
|
||||
- compiler: "node-latest-mason-linux-debug"
|
||||
env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node"
|
||||
- compiler: "mason-osx-release-node-lts"
|
||||
env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="--lts"
|
||||
- compiler: "node-lts-mason-linux-release"
|
||||
env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts"
|
||||
- compiler: "node-lts-mason-linux-debug"
|
||||
env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts"
|
||||
|
||||
before_install:
|
||||
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
|
||||
- source $NVM_DIR/nvm.sh
|
||||
- nvm install $NODE
|
||||
- nvm use $NODE
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
# Unreleased
|
||||
- Changes from 5.21.0
|
||||
- Build:
|
||||
- ADDED: optionally build Node `lts` and `latest` bindings [#5347](https://github.com/Project-OSRM/osrm-backend/pull/5347)
|
||||
- Features:
|
||||
- ADDED: new waypoints parameter to the `route` plugin, enabling silent waypoints [#5345](https://github.com/Project-OSRM/osrm-backend/pull/5345)
|
||||
- ADDED: data timestamp information in the response (saved in new file `.osrm.timestamp`). [#5115](https://github.com/Project-OSRM/osrm-backend/issues/5115)
|
||||
- ADDED: new API parameter - `snapping=any|default` to allow snapping to previously unsnappable edges [#5361](https://github.com/Project-OSRM/osrm-backend/pull/5361)
|
||||
- Routing:
|
||||
- CHANGED: allow routing past `barrier=arch` [#5352](https://github.com/Project-OSRM/osrm-backend/pull/5352)
|
||||
|
||||
# 5.21.0
|
||||
- Changes from 5.20.0
|
||||
- Features:
|
||||
|
||||
@@ -58,16 +58,16 @@ Download OpenStreetMap extracts for example from [Geofabrik](http://download.geo
|
||||
|
||||
Pre-process the extract with the car profile and start a routing engine HTTP server on port 5000
|
||||
|
||||
docker run -t -v $(pwd):/data osrm/osrm-backend osrm-extract -p /opt/car.lua /data/berlin-latest.osm.pbf
|
||||
docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/berlin-latest.osm.pbf
|
||||
|
||||
The flag `-v $(pwd):/data` creates the directory `/data` inside the docker container and makes the current working directory `$(pwd)` available there. The file `/data/berlin-latest.osm.pbf` inside the container is referring to `$(pwd)/berlin-latest.osm.pbf` on the host.
|
||||
The flag `-v "${PWD}:/data"` creates the directory `/data` inside the docker container and makes the current working directory `"${PWD}"` available there. The file `/data/berlin-latest.osm.pbf` inside the container is referring to `"${PWD}/berlin-latest.osm.pbf"` on the host.
|
||||
|
||||
docker run -t -v $(pwd):/data osrm/osrm-backend osrm-partition /data/berlin-latest.osrm
|
||||
docker run -t -v $(pwd):/data osrm/osrm-backend osrm-customize /data/berlin-latest.osrm
|
||||
docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-partition /data/berlin-latest.osrm
|
||||
docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-customize /data/berlin-latest.osrm
|
||||
|
||||
Note that `berlin-latest.osrm` has a different file extension.
|
||||
|
||||
docker run -t -i -p 5000:5000 -v $(pwd):/data osrm/osrm-backend osrm-routed --algorithm mld /data/berlin-latest.osrm
|
||||
docker run -t -i -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld /data/berlin-latest.osrm
|
||||
|
||||
Make requests against the HTTP server
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY "FALSE")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Source Routing Machine (OSRM) is a high-performance routing engine. It combines sophisticated routing algorithms with the open and free data of the OpenStreetMap.")
|
||||
SET(CPACK_PACKAGE_CONTACT "Project OSRM <info@project-osrm.org>")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENCE.TXT")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.TXT")
|
||||
|
||||
SET(CPACK_STRIP_FILES "TRUE")
|
||||
file(GLOB_RECURSE ProfileGlob ${CMAKE_SOURCE_DIR}/profiles/*)
|
||||
|
||||
+15
-10
@@ -1,14 +1,14 @@
|
||||
FROM debian:buster-slim as builder
|
||||
FROM debian:stretch-slim as builder
|
||||
ARG DOCKER_TAG
|
||||
ARG BUILD_CONCURRENCY
|
||||
RUN mkdir -p /src && mkdir -p /opt
|
||||
COPY . /src
|
||||
WORKDIR /src
|
||||
|
||||
RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
|
||||
RUN NPROC=${BUILD_CONCURRENCY:-$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1)} && \
|
||||
apt-get update && \
|
||||
apt-get -y --no-install-recommends install cmake make git gcc g++ libbz2-dev libstxxl-dev libstxxl1v5 libxml2-dev \
|
||||
libzip-dev libboost1.67-all-dev lua5.2 liblua5.2-dev libtbb-dev -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 && \
|
||||
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
|
||||
apt-get -y --no-install-recommends install cmake make git gcc g++ libbz2-dev libxml2-dev \
|
||||
libzip-dev libboost1.62-all-dev lua5.2 liblua5.2-dev libtbb-dev -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 && \
|
||||
echo "Building OSRM ${DOCKER_TAG}" && \
|
||||
git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \
|
||||
echo "Building OSRM gitsha $(cat /opt/OSRM_GITSHA)" && \
|
||||
@@ -30,15 +30,20 @@ RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
|
||||
|
||||
# Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds
|
||||
# Only the content below ends up in the image, this helps remove /src from the image (which is large)
|
||||
FROM debian:buster-slim as runstage
|
||||
FROM debian:stretch-slim as runstage
|
||||
RUN mkdir -p /src && mkdir -p /opt
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends libboost-program-options1.67.0 libboost-regex1.67.0 \
|
||||
libboost-date-time1.67.0 libboost-chrono1.67.0 libboost-filesystem1.67.0 \
|
||||
libboost-iostreams1.67.0 libboost-thread1.67.0 expat liblua5.2-0 libtbb2 &&\
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
apt-get install -y --no-install-recommends libboost-program-options1.62.0 libboost-regex1.62.0 \
|
||||
libboost-date-time1.62.0 libboost-chrono1.62.0 libboost-filesystem1.62.0 \
|
||||
libboost-iostreams1.62.0 libboost-thread1.62.0 expat liblua5.2-0 libtbb2 &&\
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=builder /usr/local /usr/local
|
||||
COPY --from=builder /opt /opt
|
||||
RUN /usr/local/bin/osrm-extract --help && \
|
||||
/usr/local/bin/osrm-routed --help && \
|
||||
/usr/local/bin/osrm-contract --help && \
|
||||
/usr/local/bin/osrm-partition --help && \
|
||||
/usr/local/bin/osrm-customize --help
|
||||
WORKDIR /opt
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@
|
||||
# ensure that "COPY . /src" is referring to the repo root, not the directory
|
||||
# that contains the Dockerfile.
|
||||
# This script gets executed with a pwd of wherever the Dockerfile is.
|
||||
docker build --build-arg DOCKER_TAG=${DOCKER_TAG} -t $IMAGE_NAME -f Dockerfile ..
|
||||
docker build --build-arg BUILD_CONCURRENCY=${CONCURRENCY:-1} --build-arg DOCKER_TAG=${DOCKER_TAG} -t $IMAGE_NAME -f Dockerfile ..
|
||||
|
||||
+10
-1
@@ -32,6 +32,7 @@ To pass parameters to each location some options support an array like encoding:
|
||||
|hints |`{hint};{hint}[;{hint} ...]` |Hint from previous request to derive position in street network. |
|
||||
|approaches |`{approach};{approach}[;{approach} ...]` |Keep waypoints on curb side. |
|
||||
|exclude |`{class}[,{class}]` |Additive list of classes to avoid, order does not matter. |
|
||||
|snapping |`default` (default), `any` |Default snapping avoids is_startpoint (see profile) edges, `any` will snap to any edge in the graph |
|
||||
|
||||
Where the elements follow the following format:
|
||||
|
||||
@@ -70,6 +71,8 @@ curl 'http://router.project-osrm.org/route/v1/driving/polyline(ofp_Ik_vpAilAyu@t
|
||||
|
||||
### Responses
|
||||
|
||||
#### Code
|
||||
|
||||
Every response object has a `code` property containing one of the strings below or a service dependent code:
|
||||
|
||||
| Type | Description |
|
||||
@@ -87,12 +90,17 @@ Every response object has a `code` property containing one of the strings below
|
||||
- `message` is a **optional** human-readable error message. All other status types are service dependent.
|
||||
- In case of an error the HTTP status code will be `400`. Otherwise the HTTP status code will be `200` and `code` will be `Ok`.
|
||||
|
||||
#### Data version
|
||||
|
||||
Every response object has a `data_version` propetry containing timestamp from the original OpenStreetMap file. This field is optional. It can be ommited if data_version parametr was not set on osrm-extract stage or OSM file has not `osmosis_replication_timestamp` section.
|
||||
|
||||
#### Example response
|
||||
|
||||
```json
|
||||
{
|
||||
"code": "Ok",
|
||||
"message": "Everything worked"
|
||||
"message": "Everything worked",
|
||||
"data_version": "2017-11-17T21:43:02Z"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -195,6 +203,7 @@ In addition to the [general options](#general-options) the following options are
|
||||
|geometries |`polyline` (default), `polyline6`, `geojson` |Returned route geometry format (influences overview and per step) |
|
||||
|overview |`simplified` (default), `full`, `false` |Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all.|
|
||||
|continue\_straight |`default` (default), `true`, `false` |Forces the route to keep going straight at waypoints constraining uturns there even if it would be faster. Default value depends on the profile. |
|
||||
|waypoints | `{index};{index};{index}...` |Treats input coordinates indicated by given indices as waypoints in returned Match object. Default is to treat all input coordinates as waypoints. |
|
||||
|
||||
\* Please note that even if alternative routes are requested, a result cannot be guaranteed.
|
||||
|
||||
|
||||
@@ -57,7 +57,9 @@ Returns the fastest route between two or more coordinates while visiting the way
|
||||
- `options.overview` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`)
|
||||
- `options.continue_straight` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Forces the route to keep going straight at waypoints and don't do a uturn even if it would be faster. Default value depends on the profile.
|
||||
- `options.approaches` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`.
|
||||
- `options.waypoints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Indices to coordinates to treat as waypoints. If not supplied, all coordinates are waypoints. Must include first and last coordinate index.
|
||||
`null`/`true`/`false`
|
||||
- `options.snapping` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
||||
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
||||
|
||||
**Examples**
|
||||
@@ -90,6 +92,7 @@ Note: `coordinates` in the general options only supports a single `{longitude},{
|
||||
- `options.number` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of nearest segments that should be returned.
|
||||
Must be an integer greater than or equal to `1`. (optional, default `1`)
|
||||
- `options.approaches` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`.
|
||||
- `options.snapping` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
||||
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
||||
|
||||
**Examples**
|
||||
@@ -132,6 +135,7 @@ tables. Optionally returns distance table.
|
||||
- `options.fallback_speed` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Replace `null` responses in result with as-the-crow-flies estimates based on `fallback_speed`. Value is in metres/second.
|
||||
- `options.fallback_coordinate` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Either `input` (default) or `snapped`. If using a `fallback_speed`, use either the user-supplied coordinate (`input`), or the snapped coordinate (`snapped`) for calculating the as-the-crow-flies diestance between two points.
|
||||
- `options.scale_factor` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Multiply the table duration values in the table by this number for more controlled input into a route optimization solver.
|
||||
- `options.snapping` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
||||
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
||||
|
||||
**Examples**
|
||||
@@ -210,6 +214,8 @@ if they can not be matched successfully.
|
||||
- `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Standard deviation of GPS precision used for map matching. If applicable use GPS accuracy. Can be `null` for default value `5` meters or `double >= 0`.
|
||||
- `options.gaps` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Allows the input track splitting based on huge timestamp gaps between points. Either `split` or `ignore` (optional, default `split`).
|
||||
- `options.tidy` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Allows the input track modification to obtain better matching quality for noisy tracks (optional, default `false`).
|
||||
- `options.waypoints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Indices to coordinates to treat as waypoints. If not supplied, all coordinates are waypoints. Must include first and last coordinate index.
|
||||
- `options.snapping` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
||||
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
||||
|
||||
**Examples**
|
||||
@@ -274,6 +280,7 @@ Right now, the following combinations are possible:
|
||||
- `options.source` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Return route starts at `any` or `first` coordinate. (optional, default `any`)
|
||||
- `options.destination` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Return route ends at `any` or `last` coordinate. (optional, default `any`)
|
||||
- `options.approaches` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`.
|
||||
- `options.snapping` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
||||
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -35,3 +35,91 @@ Feature: Car - Allowed start/end modes
|
||||
| from | to | route | modes |
|
||||
| 1 | 2 | ab,ab | driving,driving |
|
||||
| 2 | 1 | ab,ab | driving,driving |
|
||||
|
||||
Scenario: Car - URL override of non-startpoints
|
||||
Given the node map
|
||||
"""
|
||||
a 1 b c 2 d
|
||||
"""
|
||||
|
||||
Given the query options
|
||||
| snapping | any |
|
||||
|
||||
And the ways
|
||||
| nodes | highway | access |
|
||||
| ab | service | private |
|
||||
| bc | primary | |
|
||||
| cd | service | private |
|
||||
|
||||
When I request a travel time matrix I should get
|
||||
| | 2 | c |
|
||||
| 1 | 59.1 | 35.1 |
|
||||
| b | 35.1 | 11.1 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| 1 | 2 | ab,bc,cd |
|
||||
| 2 | 1 | cd,bc,ab |
|
||||
|
||||
Scenario: Car - URL override of non-startpoints
|
||||
Given the node map
|
||||
"""
|
||||
a 1 b c 2 d
|
||||
"""
|
||||
|
||||
Given the query options
|
||||
| snapping | any |
|
||||
| bearings | 90,180; |
|
||||
|
||||
And the ways
|
||||
| nodes | highway | access |
|
||||
| ab | service | private |
|
||||
| bc | primary | |
|
||||
| cd | service | private |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| 1 | 2 | ab,bc,cd |
|
||||
| 2 | 1 | cd,bc,ab |
|
||||
|
||||
Scenario: Car - URL override of non-startpoints
|
||||
Given the node map
|
||||
"""
|
||||
a 1 b c 2 d
|
||||
"""
|
||||
|
||||
Given the query options
|
||||
| snapping | any |
|
||||
| radiuses | 100;unlimited |
|
||||
|
||||
And the ways
|
||||
| nodes | highway | access |
|
||||
| ab | service | private |
|
||||
| bc | primary | |
|
||||
| cd | service | private |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| 1 | 2 | ab,bc,cd |
|
||||
| 2 | 1 | cd,bc,ab |
|
||||
|
||||
Scenario: Car - URL override of non-startpoints
|
||||
Given the node map
|
||||
"""
|
||||
a 1 b c 2 d
|
||||
"""
|
||||
|
||||
Given the query options
|
||||
| snapping | any |
|
||||
| bearings | 90,180;0,180;; |
|
||||
|
||||
And the ways
|
||||
| nodes | highway | access |
|
||||
| ab | service | private |
|
||||
| bc | primary | |
|
||||
| cd | service | private |
|
||||
|
||||
When I request a travel time matrix I should get
|
||||
| | 2 | c |
|
||||
| 1 | 59.1 | 35.1 |
|
||||
| b | 35.1 | 11.1 |
|
||||
@@ -75,6 +75,10 @@ module.exports = function () {
|
||||
got.message = json.message || '';
|
||||
}
|
||||
|
||||
if (headers.has('data_version')) {
|
||||
got.data_version = json.data_version || '';
|
||||
}
|
||||
|
||||
if (headers.has('#')) {
|
||||
// comment column
|
||||
got['#'] = row['#'];
|
||||
|
||||
@@ -17,9 +17,26 @@ Feature: Basic Routing
|
||||
| ab |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | ab,ab |
|
||||
| b | a | ab,ab |
|
||||
| from | to | route | data_version |
|
||||
| a | b | ab,ab | |
|
||||
| b | a | ab,ab | |
|
||||
|
||||
Scenario: Data_version test
|
||||
Given the node map
|
||||
"""
|
||||
a b
|
||||
"""
|
||||
|
||||
And the extract extra arguments "--data_version cucumber_data_version"
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | data_version |
|
||||
| a | b | ab,ab | cucumber_data_version |
|
||||
| b | a | ab,ab | cucumber_data_version |
|
||||
|
||||
Scenario: Routing in between two nodes of way
|
||||
Given the node map
|
||||
|
||||
@@ -18,6 +18,53 @@ Feature: Via points
|
||||
| waypoints | route |
|
||||
| a,b,c | abc,abc,abc,abc |
|
||||
|
||||
Scenario: Simple via point with waypoints collapsing
|
||||
Given the node map
|
||||
"""
|
||||
a
|
||||
|
||||
b 1c d
|
||||
2
|
||||
|
||||
e
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ace |
|
||||
| bcd |
|
||||
|
||||
Given the query options
|
||||
| waypoints | 0;2 |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| b,1,e | bcd,ace,ace | depart,turn right,arrive |
|
||||
| b,2,e | bcd,ace,ace | depart,turn right,arrive |
|
||||
|
||||
Scenario: Simple via point with waypoints collapsing
|
||||
Given the node map
|
||||
"""
|
||||
a 2 b
|
||||
|
||||
c d
|
||||
1 3
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| bd |
|
||||
| cd |
|
||||
| ac |
|
||||
|
||||
Given the query options
|
||||
| waypoints | 0;2 |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| 1,2,3 | cd,ac,ab,bd,cd | depart,new name right,new name right,new name right,arrive |
|
||||
|
||||
Scenario: Simple via point with core factor
|
||||
Given the contract extra arguments "--core 0.8"
|
||||
Given the node map
|
||||
|
||||
@@ -63,6 +63,13 @@ namespace api
|
||||
*/
|
||||
struct BaseParameters
|
||||
{
|
||||
|
||||
enum class SnappingType
|
||||
{
|
||||
Default,
|
||||
Any
|
||||
};
|
||||
|
||||
std::vector<util::Coordinate> coordinates;
|
||||
std::vector<boost::optional<Hint>> hints;
|
||||
std::vector<boost::optional<double>> radiuses;
|
||||
@@ -73,15 +80,19 @@ struct BaseParameters
|
||||
// Adds hints to response which can be included in subsequent requests, see `hints` above.
|
||||
bool generate_hints = true;
|
||||
|
||||
SnappingType snapping = SnappingType::Default;
|
||||
|
||||
BaseParameters(const std::vector<util::Coordinate> coordinates_ = {},
|
||||
const std::vector<boost::optional<Hint>> hints_ = {},
|
||||
std::vector<boost::optional<double>> radiuses_ = {},
|
||||
std::vector<boost::optional<Bearing>> bearings_ = {},
|
||||
std::vector<boost::optional<Approach>> approaches_ = {},
|
||||
bool generate_hints_ = true,
|
||||
std::vector<std::string> exclude = {})
|
||||
std::vector<std::string> exclude = {},
|
||||
const SnappingType snapping_ = SnappingType::Default)
|
||||
: coordinates(coordinates_), hints(hints_), radiuses(radiuses_), bearings(bearings_),
|
||||
approaches(approaches_), exclude(std::move(exclude)), generate_hints(generate_hints_)
|
||||
approaches(approaches_), exclude(std::move(exclude)), generate_hints(generate_hints_),
|
||||
snapping(snapping_)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ struct MatchParameters : public RouteParameters
|
||||
RouteParameters::GeometriesType::Polyline,
|
||||
RouteParameters::OverviewType::Simplified,
|
||||
{}),
|
||||
gaps(GapsType::Split), tidy(false), waypoints()
|
||||
gaps(GapsType::Split), tidy(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -79,24 +79,19 @@ struct MatchParameters : public RouteParameters
|
||||
bool tidy_,
|
||||
std::vector<std::size_t> waypoints_,
|
||||
Args... args_)
|
||||
: RouteParameters{std::forward<Args>(args_)...}, timestamps{std::move(timestamps_)},
|
||||
gaps(gaps_), tidy(tidy_), waypoints{std::move(waypoints_)}
|
||||
: RouteParameters{std::forward<Args>(args_)..., waypoints_},
|
||||
timestamps{std::move(timestamps_)}, gaps(gaps_), tidy(tidy_)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<unsigned> timestamps;
|
||||
GapsType gaps;
|
||||
bool tidy;
|
||||
std::vector<std::size_t> waypoints;
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
const auto valid_waypoints =
|
||||
std::all_of(waypoints.begin(), waypoints.end(), [this](const auto &w) {
|
||||
return w < coordinates.size();
|
||||
});
|
||||
return RouteParameters::IsValid() &&
|
||||
(timestamps.empty() || timestamps.size() == coordinates.size()) && valid_waypoints;
|
||||
(timestamps.empty() || timestamps.size() == coordinates.size());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,8 +44,11 @@ class RouteAPI : public BaseAPI
|
||||
{
|
||||
}
|
||||
|
||||
void MakeResponse(const InternalManyRoutesResult &raw_routes,
|
||||
util::json::Object &response) const
|
||||
void
|
||||
MakeResponse(const InternalManyRoutesResult &raw_routes,
|
||||
const std::vector<PhantomNodes>
|
||||
&all_start_end_points, // all used coordinates, ignoring waypoints= parameter
|
||||
util::json::Object &response) const
|
||||
{
|
||||
BOOST_ASSERT(!raw_routes.routes.empty());
|
||||
|
||||
@@ -62,10 +65,14 @@ class RouteAPI : public BaseAPI
|
||||
route.target_traversed_in_reverse));
|
||||
}
|
||||
|
||||
response.values["waypoints"] =
|
||||
BaseAPI::MakeWaypoints(raw_routes.routes[0].segment_end_coordinates);
|
||||
response.values["waypoints"] = BaseAPI::MakeWaypoints(all_start_end_points);
|
||||
response.values["routes"] = std::move(jsRoutes);
|
||||
response.values["code"] = "Ok";
|
||||
auto data_timestamp = facade.GetTimestamp();
|
||||
if (!data_timestamp.empty())
|
||||
{
|
||||
response.values["data_version"] = data_timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -98,7 +98,8 @@ struct RouteParameters : public BaseParameters
|
||||
annotations_type{AnnotationsType::None},
|
||||
geometries{geometries_},
|
||||
overview{overview_},
|
||||
continue_straight{continue_straight_}
|
||||
continue_straight{continue_straight_},
|
||||
waypoints()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -114,7 +115,9 @@ struct RouteParameters : public BaseParameters
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_},
|
||||
annotations_type{annotations_ ? AnnotationsType::All : AnnotationsType::None},
|
||||
geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_}
|
||||
geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_},
|
||||
waypoints()
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@@ -131,7 +134,43 @@ struct RouteParameters : public BaseParameters
|
||||
number_of_alternatives{alternatives_ ? 1u : 0u},
|
||||
annotations{annotations_ == AnnotationsType::None ? false : true},
|
||||
annotations_type{annotations_}, geometries{geometries_}, overview{overview_},
|
||||
continue_straight{continue_straight_}
|
||||
continue_straight{continue_straight_}, waypoints()
|
||||
{
|
||||
}
|
||||
|
||||
// RouteParameters constructor adding the `waypoints` parameter
|
||||
template <typename... Args>
|
||||
RouteParameters(const bool steps_,
|
||||
const bool alternatives_,
|
||||
const bool annotations_,
|
||||
const GeometriesType geometries_,
|
||||
const OverviewType overview_,
|
||||
const boost::optional<bool> continue_straight_,
|
||||
std::vector<std::size_t> waypoints_,
|
||||
const Args... args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_},
|
||||
annotations_type{annotations_ ? AnnotationsType::All : AnnotationsType::None},
|
||||
geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_},
|
||||
waypoints{waypoints_}
|
||||
{
|
||||
}
|
||||
|
||||
// RouteParameters constructor adding the `waypoints` parameter
|
||||
template <typename... Args>
|
||||
RouteParameters(const bool steps_,
|
||||
const bool alternatives_,
|
||||
const AnnotationsType annotations_,
|
||||
const GeometriesType geometries_,
|
||||
const OverviewType overview_,
|
||||
const boost::optional<bool> continue_straight_,
|
||||
std::vector<std::size_t> waypoints_,
|
||||
Args... args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
number_of_alternatives{alternatives_ ? 1u : 0u},
|
||||
annotations{annotations_ == AnnotationsType::None ? false : true},
|
||||
annotations_type{annotations_}, geometries{geometries_}, overview{overview_},
|
||||
continue_straight{continue_straight_}, waypoints{waypoints_}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -144,12 +183,17 @@ struct RouteParameters : public BaseParameters
|
||||
GeometriesType geometries = GeometriesType::Polyline;
|
||||
OverviewType overview = OverviewType::Simplified;
|
||||
boost::optional<bool> continue_straight;
|
||||
std::vector<std::size_t> waypoints;
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
const auto coordinates_ok = coordinates.size() >= 2;
|
||||
const auto base_params_ok = BaseParameters::IsValid();
|
||||
return coordinates_ok && base_params_ok;
|
||||
const auto valid_waypoints =
|
||||
std::all_of(waypoints.begin(), waypoints.end(), [this](const auto &w) {
|
||||
return w < coordinates.size();
|
||||
});
|
||||
return coordinates_ok && base_params_ok && valid_waypoints;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -173,8 +217,8 @@ inline RouteParameters::AnnotationsType operator|=(RouteParameters::AnnotationsT
|
||||
{
|
||||
return lhs = lhs | rhs;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // ns api
|
||||
} // ns engine
|
||||
} // ns osrm
|
||||
|
||||
#endif
|
||||
|
||||
@@ -137,6 +137,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
extractor::Datasources *m_datasources;
|
||||
|
||||
std::uint32_t m_check_sum;
|
||||
StringView m_data_timestamp;
|
||||
util::vector_view<util::Coordinate> m_coordinate_list;
|
||||
extractor::PackedOSMIDsView m_osmnodeid_list;
|
||||
util::vector_view<std::uint32_t> m_lane_description_offsets;
|
||||
@@ -183,6 +184,8 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
|
||||
m_check_sum = *index.GetBlockPtr<std::uint32_t>("/common/connectivity_checksum");
|
||||
|
||||
m_data_timestamp = make_timestamp_view(index, "/common/timestamp");
|
||||
|
||||
std::tie(m_coordinate_list, m_osmnodeid_list) =
|
||||
make_nbn_data_view(index, "/common/nbn_data");
|
||||
|
||||
@@ -386,23 +389,25 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const Approach approach) const override final
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const override final
|
||||
{
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
input_coordinate, approach);
|
||||
input_coordinate, approach, use_all_edges);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const Approach approach) const override final
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const override final
|
||||
{
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
input_coordinate, max_distance, approach);
|
||||
input_coordinate, max_distance, approach, use_all_edges);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
@@ -410,28 +415,35 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range,
|
||||
const Approach approach) const override final
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const override final
|
||||
{
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
input_coordinate, max_distance, bearing, bearing_range, approach);
|
||||
input_coordinate, max_distance, bearing, bearing_range, approach, use_all_edges);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const int bearing,
|
||||
const int bearing_range,
|
||||
const Approach approach) const override final
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const override final
|
||||
{
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
input_coordinate, bearing, bearing_range, approach);
|
||||
input_coordinate, bearing, bearing_range, approach, use_all_edges);
|
||||
}
|
||||
|
||||
std::uint32_t GetCheckSum() const override final { return m_check_sum; }
|
||||
|
||||
std::string GetTimestamp() const override final
|
||||
{
|
||||
return std::string(m_data_timestamp.begin(), m_data_timestamp.end());
|
||||
}
|
||||
|
||||
GeometryID GetGeometryIndex(const NodeID id) const override final
|
||||
{
|
||||
return edge_based_node_data.GetGeometryID(id);
|
||||
|
||||
@@ -74,6 +74,8 @@ class BaseDataFacade
|
||||
|
||||
virtual std::uint32_t GetCheckSum() const = 0;
|
||||
|
||||
virtual std::string GetTimestamp() const = 0;
|
||||
|
||||
// node and edge information access
|
||||
virtual util::Coordinate GetCoordinateOfNode(const NodeID id) const = 0;
|
||||
|
||||
@@ -159,22 +161,26 @@ class BaseDataFacade
|
||||
|
||||
virtual std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const Approach approach) const = 0;
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const = 0;
|
||||
virtual std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const Approach approach) const = 0;
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const = 0;
|
||||
virtual std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range,
|
||||
const Approach approach) const = 0;
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const = 0;
|
||||
virtual std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const int bearing,
|
||||
const int bearing_range,
|
||||
const Approach approach) const = 0;
|
||||
const Approach approach,
|
||||
const bool use_all_edges = false) const = 0;
|
||||
|
||||
virtual bool HasLaneData(const EdgeID id) const = 0;
|
||||
virtual util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const = 0;
|
||||
|
||||
@@ -205,18 +205,23 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const Approach approach) const
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const
|
||||
{
|
||||
bool has_small_component = false;
|
||||
bool has_big_component = false;
|
||||
auto results = rtree.Nearest(
|
||||
input_coordinate,
|
||||
[this, approach, &input_coordinate, &has_big_component, &has_small_component](
|
||||
const CandidateSegment &segment) {
|
||||
[this,
|
||||
approach,
|
||||
&input_coordinate,
|
||||
&has_big_component,
|
||||
&has_small_component,
|
||||
&use_all_edges](const CandidateSegment &segment) {
|
||||
auto use_segment =
|
||||
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||
const auto valid_edges = HasValidEdge(segment);
|
||||
const auto valid_edges = HasValidEdge(segment, use_all_edges);
|
||||
const auto admissible_segments = CheckSegmentExclude(segment);
|
||||
use_directions = boolPairAnd(use_directions, admissible_segments);
|
||||
use_directions = boolPairAnd(use_directions, valid_edges);
|
||||
@@ -251,19 +256,24 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
// a second phantom node is return that is the nearest coordinate in a big component.
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const Approach approach) const
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const
|
||||
{
|
||||
bool has_small_component = false;
|
||||
bool has_big_component = false;
|
||||
auto results = rtree.Nearest(
|
||||
input_coordinate,
|
||||
[this, approach, &input_coordinate, &has_big_component, &has_small_component](
|
||||
const CandidateSegment &segment) {
|
||||
[this,
|
||||
approach,
|
||||
&input_coordinate,
|
||||
&has_big_component,
|
||||
&has_small_component,
|
||||
&use_all_edges](const CandidateSegment &segment) {
|
||||
auto use_segment =
|
||||
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||
|
||||
const auto valid_edges = HasValidEdge(segment);
|
||||
const auto valid_edges = HasValidEdge(segment, use_all_edges);
|
||||
const auto admissible_segments = CheckSegmentExclude(segment);
|
||||
use_directions = boolPairAnd(use_directions, admissible_segments);
|
||||
use_directions = boolPairAnd(use_directions, valid_edges);
|
||||
@@ -298,7 +308,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const int bearing,
|
||||
const int bearing_range,
|
||||
const Approach approach) const
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const
|
||||
{
|
||||
bool has_small_component = false;
|
||||
bool has_big_component = false;
|
||||
@@ -310,18 +321,18 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
bearing,
|
||||
bearing_range,
|
||||
&has_big_component,
|
||||
&has_small_component](const CandidateSegment &segment) {
|
||||
&has_small_component,
|
||||
&use_all_edges](const CandidateSegment &segment) {
|
||||
auto use_segment =
|
||||
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||
const auto admissible_segments = CheckSegmentExclude(segment);
|
||||
use_directions = boolPairAnd(use_directions, HasValidEdge(segment));
|
||||
|
||||
if (use_segment)
|
||||
{
|
||||
use_directions =
|
||||
boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range),
|
||||
HasValidEdge(segment));
|
||||
HasValidEdge(segment, use_all_edges));
|
||||
use_directions = boolPairAnd(use_directions, admissible_segments);
|
||||
use_directions = boolPairAnd(
|
||||
use_directions, CheckApproach(input_coordinate, segment, approach));
|
||||
@@ -356,7 +367,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range,
|
||||
const Approach approach) const
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const
|
||||
{
|
||||
bool has_small_component = false;
|
||||
bool has_big_component = false;
|
||||
@@ -368,18 +380,18 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
bearing,
|
||||
bearing_range,
|
||||
&has_big_component,
|
||||
&has_small_component](const CandidateSegment &segment) {
|
||||
&has_small_component,
|
||||
&use_all_edges](const CandidateSegment &segment) {
|
||||
auto use_segment =
|
||||
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||
const auto admissible_segments = CheckSegmentExclude(segment);
|
||||
use_directions = boolPairAnd(use_directions, HasValidEdge(segment));
|
||||
|
||||
if (use_segment)
|
||||
{
|
||||
use_directions =
|
||||
boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range),
|
||||
HasValidEdge(segment));
|
||||
HasValidEdge(segment, use_all_edges));
|
||||
use_directions = boolPairAnd(use_directions, admissible_segments);
|
||||
use_directions = boolPairAnd(
|
||||
use_directions, CheckApproach(input_coordinate, segment, approach));
|
||||
|
||||
@@ -270,6 +270,7 @@ class BasePlugin
|
||||
const bool use_bearings = !parameters.bearings.empty();
|
||||
const bool use_radiuses = !parameters.radiuses.empty();
|
||||
const bool use_approaches = !parameters.approaches.empty();
|
||||
const bool use_all_edges = parameters.snapping == api::BaseParameters::SnappingType::Any;
|
||||
|
||||
BOOST_ASSERT(parameters.IsValid());
|
||||
for (const auto i : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
|
||||
@@ -296,7 +297,8 @@ class BasePlugin
|
||||
*parameters.radiuses[i],
|
||||
parameters.bearings[i]->bearing,
|
||||
parameters.bearings[i]->range,
|
||||
approach);
|
||||
approach,
|
||||
use_all_edges);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -305,7 +307,8 @@ class BasePlugin
|
||||
parameters.coordinates[i],
|
||||
parameters.bearings[i]->bearing,
|
||||
parameters.bearings[i]->range,
|
||||
approach);
|
||||
approach,
|
||||
use_all_edges);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -314,13 +317,16 @@ class BasePlugin
|
||||
{
|
||||
phantom_node_pairs[i] =
|
||||
facade.NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
parameters.coordinates[i], *parameters.radiuses[i], approach);
|
||||
parameters.coordinates[i],
|
||||
*parameters.radiuses[i],
|
||||
approach,
|
||||
use_all_edges);
|
||||
}
|
||||
else
|
||||
{
|
||||
phantom_node_pairs[i] =
|
||||
facade.NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
parameters.coordinates[i], approach);
|
||||
parameters.coordinates[i], approach, use_all_edges);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ struct ExtractorConfig final : storage::IOConfig
|
||||
".osrm.geometry",
|
||||
".osrm.nbg_nodes",
|
||||
".osrm.ebg_nodes",
|
||||
".osrm.timestamp",
|
||||
".osrm.edges",
|
||||
".osrm.ebg",
|
||||
".osrm.ramIndex",
|
||||
@@ -82,6 +83,7 @@ struct ExtractorConfig final : storage::IOConfig
|
||||
boost::filesystem::path input_path;
|
||||
boost::filesystem::path profile_path;
|
||||
std::vector<boost::filesystem::path> location_dependent_data_paths;
|
||||
std::string data_version;
|
||||
|
||||
unsigned requested_num_threads;
|
||||
unsigned small_component_size;
|
||||
|
||||
@@ -308,6 +308,26 @@ inline void writeTurnLaneData(const boost::filesystem::path &path,
|
||||
storage::serialization::write(writer, "/common/turn_lanes/data", turn_lane_data);
|
||||
}
|
||||
|
||||
// reads .osrm.timestamp
|
||||
template <typename TimestampDataT>
|
||||
inline void readTimestamp(const boost::filesystem::path &path, TimestampDataT ×tamp)
|
||||
{
|
||||
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
|
||||
storage::tar::FileReader reader{path, fingerprint};
|
||||
|
||||
storage::serialization::read(reader, "/common/timestamp", timestamp);
|
||||
}
|
||||
|
||||
// writes .osrm.timestamp
|
||||
template <typename TimestampDataT>
|
||||
inline void writeTimestamp(const boost::filesystem::path &path, const TimestampDataT ×tamp)
|
||||
{
|
||||
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
|
||||
storage::tar::FileWriter writer{path, fingerprint};
|
||||
|
||||
storage::serialization::write(writer, "/common/timestamp", timestamp);
|
||||
}
|
||||
|
||||
// reads .osrm.maneuver_overrides
|
||||
template <typename StorageManeuverOverrideT, typename NodeSequencesT>
|
||||
inline void readManeuverOverrides(const boost::filesystem::path &path,
|
||||
|
||||
@@ -944,6 +944,101 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
|
||||
}
|
||||
}
|
||||
|
||||
if (obj->Has(Nan::New("waypoints").ToLocalChecked()))
|
||||
{
|
||||
v8::Local<v8::Value> waypoints = obj->Get(Nan::New("waypoints").ToLocalChecked());
|
||||
if (waypoints.IsEmpty())
|
||||
return route_parameters_ptr();
|
||||
|
||||
// must be array
|
||||
if (!waypoints->IsArray())
|
||||
{
|
||||
Nan::ThrowError(
|
||||
"Waypoints must be an array of integers corresponding to the input coordinates.");
|
||||
return route_parameters_ptr();
|
||||
}
|
||||
|
||||
auto waypoints_array = v8::Local<v8::Array>::Cast(waypoints);
|
||||
// must have at least two elements
|
||||
if (waypoints_array->Length() < 2)
|
||||
{
|
||||
Nan::ThrowError("At least two waypoints must be provided");
|
||||
return route_parameters_ptr();
|
||||
}
|
||||
auto coords_size = params->coordinates.size();
|
||||
auto waypoints_array_size = waypoints_array->Length();
|
||||
|
||||
const auto first_index = Nan::To<std::uint32_t>(waypoints_array->Get(0)).FromJust();
|
||||
const auto last_index =
|
||||
Nan::To<std::uint32_t>(waypoints_array->Get(waypoints_array_size - 1)).FromJust();
|
||||
if (first_index != 0 || last_index != coords_size - 1)
|
||||
{
|
||||
Nan::ThrowError("First and last waypoints values must correspond to first and last "
|
||||
"coordinate indices");
|
||||
return route_parameters_ptr();
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < waypoints_array_size; ++i)
|
||||
{
|
||||
v8::Local<v8::Value> waypoint_value = waypoints_array->Get(i);
|
||||
// all elements must be numbers
|
||||
if (!waypoint_value->IsNumber())
|
||||
{
|
||||
Nan::ThrowError("Waypoint values must be an array of integers");
|
||||
return route_parameters_ptr();
|
||||
}
|
||||
// check that the waypoint index corresponds with an inpute coordinate
|
||||
const auto index = Nan::To<std::uint32_t>(waypoint_value).FromJust();
|
||||
if (index >= coords_size)
|
||||
{
|
||||
Nan::ThrowError("Waypoints must correspond with the index of an input coordinate");
|
||||
return route_parameters_ptr();
|
||||
}
|
||||
params->waypoints.emplace_back(static_cast<unsigned>(waypoint_value->NumberValue()));
|
||||
}
|
||||
|
||||
if (!params->waypoints.empty())
|
||||
{
|
||||
for (std::size_t i = 0; i < params->waypoints.size() - 1; i++)
|
||||
{
|
||||
if (params->waypoints[i] >= params->waypoints[i + 1])
|
||||
{
|
||||
Nan::ThrowError("Waypoints must be supplied in increasing order");
|
||||
return route_parameters_ptr();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj->Has(Nan::New("snapping").ToLocalChecked()))
|
||||
{
|
||||
v8::Local<v8::Value> snapping = obj->Get(Nan::New("snapping").ToLocalChecked());
|
||||
if (snapping.IsEmpty())
|
||||
return route_parameters_ptr();
|
||||
|
||||
if (!snapping->IsString())
|
||||
{
|
||||
Nan::ThrowError("Snapping must be a string: [default, any]");
|
||||
return route_parameters_ptr();
|
||||
}
|
||||
const Nan::Utf8String snapping_utf8str(snapping);
|
||||
std::string snapping_str{*snapping_utf8str, *snapping_utf8str + snapping_utf8str.length()};
|
||||
|
||||
if (snapping_str == "default")
|
||||
{
|
||||
params->snapping = osrm::RouteParameters::SnappingType::Default;
|
||||
}
|
||||
else if (snapping_str == "any")
|
||||
{
|
||||
params->snapping = osrm::RouteParameters::SnappingType::Any;
|
||||
}
|
||||
else
|
||||
{
|
||||
Nan::ThrowError("'snapping' param must be one of [default, any]");
|
||||
return route_parameters_ptr();
|
||||
}
|
||||
}
|
||||
|
||||
bool parsedSuccessfully = parseCommonParameters(obj, params);
|
||||
if (!parsedSuccessfully)
|
||||
{
|
||||
|
||||
@@ -162,6 +162,13 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
||||
(-approach_type %
|
||||
';')[ph::bind(&engine::api::BaseParameters::approaches, qi::_r1) = qi::_1];
|
||||
|
||||
snapping_type.add("default", engine::api::BaseParameters::SnappingType::Default)(
|
||||
"any", engine::api::BaseParameters::SnappingType::Any);
|
||||
|
||||
snapping_rule =
|
||||
qi::lit("snapping=") >
|
||||
snapping_type[ph::bind(&engine::api::BaseParameters::snapping, qi::_r1) = qi::_1];
|
||||
|
||||
exclude_rule = qi::lit("exclude=") >
|
||||
(qi::as_string[+qi::char_("a-zA-Z0-9")] %
|
||||
',')[ph::bind(&engine::api::BaseParameters::exclude, qi::_r1) = qi::_1];
|
||||
@@ -171,7 +178,8 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
||||
| bearings_rule(qi::_r1) //
|
||||
| generate_hints_rule(qi::_r1) //
|
||||
| approach_rule(qi::_r1) //
|
||||
| exclude_rule(qi::_r1);
|
||||
| exclude_rule(qi::_r1) //
|
||||
| snapping_rule(qi::_r1);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -197,8 +205,10 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
||||
qi::rule<Iterator, unsigned char()> base64_char;
|
||||
qi::rule<Iterator, std::string()> polyline_chars;
|
||||
qi::rule<Iterator, double()> unlimited_rule;
|
||||
qi::rule<Iterator, Signature> snapping_rule;
|
||||
|
||||
qi::symbols<char, engine::Approach> approach_type;
|
||||
qi::symbols<char, engine::api::BaseParameters::SnappingType> snapping_type;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,17 +42,12 @@ struct MatchParametersGrammar final : public RouteParametersGrammar<Iterator, Si
|
||||
(qi::uint_ %
|
||||
';')[ph::bind(&engine::api::MatchParameters::timestamps, qi::_r1) = qi::_1];
|
||||
|
||||
waypoints_rule =
|
||||
qi::lit("waypoints=") >
|
||||
(size_t_ % ';')[ph::bind(&engine::api::MatchParameters::waypoints, qi::_r1) = qi::_1];
|
||||
|
||||
gaps_type.add("split", engine::api::MatchParameters::GapsType::Split)(
|
||||
"ignore", engine::api::MatchParameters::GapsType::Ignore);
|
||||
|
||||
root_rule =
|
||||
BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
|
||||
-('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1) |
|
||||
waypoints_rule(qi::_r1) |
|
||||
(qi::lit("gaps=") >
|
||||
gaps_type[ph::bind(&engine::api::MatchParameters::gaps, qi::_r1) = qi::_1]) |
|
||||
(qi::lit("tidy=") >
|
||||
@@ -63,7 +58,6 @@ struct MatchParametersGrammar final : public RouteParametersGrammar<Iterator, Si
|
||||
private:
|
||||
qi::rule<Iterator, Signature> root_rule;
|
||||
qi::rule<Iterator, Signature> timestamps_rule;
|
||||
qi::rule<Iterator, Signature> waypoints_rule;
|
||||
qi::rule<Iterator, std::size_t()> size_t_;
|
||||
|
||||
qi::symbols<char, engine::api::MatchParameters::GapsType> gaps_type;
|
||||
|
||||
@@ -48,6 +48,14 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
|
||||
|
||||
RouteParametersGrammar(qi::rule<Iterator, Signature> &root_rule_) : BaseGrammar(root_rule_)
|
||||
{
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
if (std::is_same<std::size_t, unsigned long long>::value)
|
||||
size_t_ = qi::ulong_long;
|
||||
else
|
||||
size_t_ = qi::ulong_;
|
||||
#else
|
||||
size_t_ = qi::ulong_;
|
||||
#endif
|
||||
using AnnotationsType = engine::api::RouteParameters::AnnotationsType;
|
||||
|
||||
const auto add_annotation = [](engine::api::RouteParameters &route_parameters,
|
||||
@@ -70,8 +78,12 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
|
||||
"distance", AnnotationsType::Distance)("weight", AnnotationsType::Weight)(
|
||||
"datasources", AnnotationsType::Datasources)("speed", AnnotationsType::Speed);
|
||||
|
||||
waypoints_rule =
|
||||
qi::lit("waypoints=") >
|
||||
(size_t_ % ';')[ph::bind(&engine::api::RouteParameters::waypoints, qi::_r1) = qi::_1];
|
||||
|
||||
base_rule =
|
||||
BaseGrammar::base_rule(qi::_r1) |
|
||||
BaseGrammar::base_rule(qi::_r1) | waypoints_rule(qi::_r1) |
|
||||
(qi::lit("steps=") >
|
||||
qi::bool_[ph::bind(&engine::api::RouteParameters::steps, qi::_r1) = qi::_1]) |
|
||||
(qi::lit("geometries=") >
|
||||
@@ -94,6 +106,8 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
|
||||
private:
|
||||
qi::rule<Iterator, Signature> root_rule;
|
||||
qi::rule<Iterator, Signature> route_rule;
|
||||
qi::rule<Iterator, Signature> waypoints_rule;
|
||||
qi::rule<Iterator, std::size_t()> size_t_;
|
||||
|
||||
qi::symbols<char, engine::api::RouteParameters::GeometriesType> geometries_type;
|
||||
qi::symbols<char, engine::api::RouteParameters::OverviewType> overview_type;
|
||||
|
||||
@@ -58,6 +58,7 @@ struct StorageConfig final : IOConfig
|
||||
".osrm.turn_duration_penalties",
|
||||
".osrm.datasource_names",
|
||||
".osrm.names",
|
||||
".osrm.timestamp",
|
||||
".osrm.properties",
|
||||
".osrm.icd",
|
||||
".osrm.maneuver_overrides"},
|
||||
|
||||
@@ -272,6 +272,11 @@ inline auto make_partition_view(const SharedDataIndex &index, const std::string
|
||||
level_data_ptr, std::move(partition), std::move(cell_to_children)};
|
||||
}
|
||||
|
||||
inline auto make_timestamp_view(const SharedDataIndex &index, const std::string &name)
|
||||
{
|
||||
return util::StringView(index.GetBlockPtr<char>(name), index.GetBlockEntries(name));
|
||||
}
|
||||
|
||||
inline auto make_cell_storage_view(const SharedDataIndex &index, const std::string &name)
|
||||
{
|
||||
auto source_boundary = make_vector_view<NodeID>(index, name + "/source_boundary");
|
||||
|
||||
@@ -79,6 +79,7 @@ using EdgeDistance = float;
|
||||
using SegmentWeight = std::uint32_t;
|
||||
using SegmentDuration = std::uint32_t;
|
||||
using TurnPenalty = std::int16_t; // turn penalty in 100ms units
|
||||
using DataTimestamp = std::string;
|
||||
|
||||
static const std::size_t INVALID_INDEX = std::numeric_limits<std::size_t>::max();
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "osrm",
|
||||
"version": "5.21.0",
|
||||
"version": "5.22.0-customsnapping.3",
|
||||
"private": false,
|
||||
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
|
||||
"dependencies": {
|
||||
|
||||
+2
-1
@@ -60,7 +60,8 @@ function setup()
|
||||
'lift_gate',
|
||||
'no',
|
||||
'entrance',
|
||||
'height_restrictor'
|
||||
'height_restrictor',
|
||||
'arch'
|
||||
},
|
||||
|
||||
access_tag_whitelist = Set {
|
||||
|
||||
@@ -73,6 +73,16 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
||||
return Error("InvalidValue", "Invalid coordinate value.", json_result);
|
||||
}
|
||||
|
||||
// Error: first and last points should be waypoints
|
||||
if (!route_parameters.waypoints.empty() &&
|
||||
(route_parameters.waypoints[0] != 0 ||
|
||||
route_parameters.waypoints.back() != (route_parameters.coordinates.size() - 1)))
|
||||
{
|
||||
return Error("InvalidValue",
|
||||
"First and last coordinates must be specified as waypoints.",
|
||||
json_result);
|
||||
}
|
||||
|
||||
if (!CheckAlgorithms(route_parameters, algorithms, json_result))
|
||||
return Status::Error;
|
||||
|
||||
@@ -132,7 +142,27 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
||||
|
||||
if (routes.routes[0].is_valid())
|
||||
{
|
||||
route_api.MakeResponse(routes, json_result);
|
||||
auto collapse_legs = !route_parameters.waypoints.empty();
|
||||
if (collapse_legs)
|
||||
{
|
||||
std::vector<bool> waypoint_legs(route_parameters.coordinates.size(), false);
|
||||
std::for_each(route_parameters.waypoints.begin(),
|
||||
route_parameters.waypoints.end(),
|
||||
[&](const std::size_t waypoint_index) {
|
||||
BOOST_ASSERT(waypoint_index < waypoint_legs.size());
|
||||
waypoint_legs[waypoint_index] = true;
|
||||
});
|
||||
// First and last coordinates should always be waypoints
|
||||
// This gets validated earlier, but double-checking here, jic
|
||||
BOOST_ASSERT(waypoint_legs.front());
|
||||
BOOST_ASSERT(waypoint_legs.back());
|
||||
for (std::size_t i = 0; i < routes.routes.size(); i++)
|
||||
{
|
||||
routes.routes[i] = CollapseInternalRouteResult(routes.routes[i], waypoint_legs);
|
||||
}
|
||||
}
|
||||
|
||||
route_api.MakeResponse(routes, start_end_nodes, json_result);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include <osmium/handler/node_locations_for_ways.hpp>
|
||||
#include <osmium/index/map/flex_mem.hpp>
|
||||
#include <osmium/io/any_input.hpp>
|
||||
#include <osmium/osm/timestamp.hpp>
|
||||
#include <osmium/thread/pool.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
@@ -425,6 +426,14 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
|
||||
|
||||
// write .timestamp data file
|
||||
std::string timestamp = header.get("osmosis_replication_timestamp");
|
||||
if (config.data_version == "osmosis")
|
||||
{
|
||||
files::writeTimestamp(config.GetPath(".osrm.timestamp").string(), timestamp);
|
||||
}
|
||||
else
|
||||
{
|
||||
files::writeTimestamp(config.GetPath(".osrm.timestamp").string(), config.data_version);
|
||||
}
|
||||
if (timestamp.empty())
|
||||
{
|
||||
timestamp = "n/a";
|
||||
|
||||
@@ -302,6 +302,7 @@ std::vector<std::pair<bool, boost::filesystem::path>> Storage::GetStaticFiles()
|
||||
{REQUIRED, config.GetPath(".osrm.ebg_nodes")},
|
||||
{REQUIRED, config.GetPath(".osrm.tls")},
|
||||
{REQUIRED, config.GetPath(".osrm.tld")},
|
||||
{REQUIRED, config.GetPath(".osrm.timestamp")},
|
||||
{REQUIRED, config.GetPath(".osrm.maneuver_overrides")},
|
||||
{REQUIRED, config.GetPath(".osrm.edges")},
|
||||
{REQUIRED, config.GetPath(".osrm.names")},
|
||||
@@ -401,6 +402,17 @@ void Storage::PopulateStaticData(const SharedDataIndex &index)
|
||||
extractor::files::readNames(config.GetPath(".osrm.names"), name_table);
|
||||
}
|
||||
|
||||
// Timestamp mark
|
||||
{
|
||||
auto timestamp_ref = make_timestamp_view(index, "/common/timestamp");
|
||||
std::string ts;
|
||||
extractor::files::readTimestamp(config.GetPath(".osrm.timestamp"), ts);
|
||||
if (!ts.empty())
|
||||
{
|
||||
memcpy(const_cast<char *>(timestamp_ref.data()), ts.data(), ts.size());
|
||||
}
|
||||
}
|
||||
|
||||
// Turn lane data
|
||||
{
|
||||
auto turn_lane_data = make_lane_data_view(index, "/common/turn_lanes");
|
||||
|
||||
@@ -43,6 +43,10 @@ return_code parseArguments(int argc,
|
||||
boost::program_options::value<boost::filesystem::path>(&extractor_config.profile_path)
|
||||
->default_value("profiles/car.lua"),
|
||||
"Path to LUA routing profile")(
|
||||
"data_version,d",
|
||||
boost::program_options::value<std::string>(&extractor_config.data_version)
|
||||
->default_value(""),
|
||||
"Data version. Leave blank to avoid. osmosis - to get timestamp from file")(
|
||||
"threads,t",
|
||||
boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads)
|
||||
->default_value(tbb::task_scheduler_init::default_num_threads()),
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@
|
||||
"description": "High-performance routing engine for shortest paths in road networks.",
|
||||
"project_url": "http://project-osrm.org",
|
||||
"icon_url": "http://project-osrm.org/images/osrm_icon.png",
|
||||
"contact_name": "Patrick Niklaus",
|
||||
"contact_email": "patrick@mapbox.com"
|
||||
"contact_name": "Daniel Patterson",
|
||||
"contact_email": "daniel@mapbox.com"
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
|
||||
@@ -319,6 +319,30 @@ test('match: throws on invalid waypoints values, waypoints must correspond with
|
||||
'Waypoints must correspond with the index of an input coordinate');
|
||||
});
|
||||
|
||||
test('match: throws on invalid waypoints values, waypoints must be an array', function (assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(data_path);
|
||||
var options = {
|
||||
steps: true,
|
||||
coordinates: three_test_coordinates,
|
||||
waypoints: "string"
|
||||
};
|
||||
assert.throws(function () { osrm.match(options, function (err, response) { console.log(err); }); },
|
||||
'Waypoints must be an array of integers corresponding to the input coordinates.');
|
||||
});
|
||||
|
||||
test('match: throws on invalid waypoints values, waypoints must be an array of integers', function (assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(data_path);
|
||||
var options = {
|
||||
steps: true,
|
||||
coordinates: three_test_coordinates,
|
||||
waypoints: [0,1,"string"]
|
||||
};
|
||||
assert.throws(function () { osrm.match(options, function (err, response) { console.log(err); }); },
|
||||
'Waypoint values must be an array of integers');
|
||||
});
|
||||
|
||||
test('match: error on split trace', function(assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(data_path);
|
||||
|
||||
@@ -606,3 +606,108 @@ test('route: route in Monaco without motorways', function(assert) {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test('route: throws on invalid waypoints values needs at least two', function (assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(monaco_path);
|
||||
var options = {
|
||||
steps: true,
|
||||
coordinates: three_test_coordinates,
|
||||
waypoints: [0]
|
||||
};
|
||||
assert.throws(function () { osrm.route(options, function (err, response) { }); },
|
||||
'At least two waypoints must be provided');
|
||||
});
|
||||
|
||||
test('route: throws on invalid waypoints values, needs first and last coordinate indices', function (assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(monaco_path);
|
||||
var options = {
|
||||
steps: true,
|
||||
coordinates: three_test_coordinates,
|
||||
waypoints: [1, 2]
|
||||
};
|
||||
assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); },
|
||||
'First and last waypoints values must correspond to first and last coordinate indices');
|
||||
});
|
||||
|
||||
test('route: throws on invalid waypoints values, order matters', function (assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(monaco_path);
|
||||
var options = {
|
||||
steps: true,
|
||||
coordinates: three_test_coordinates,
|
||||
waypoints: [2, 0]
|
||||
};
|
||||
assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); },
|
||||
'First and last waypoints values must correspond to first and last coordinate indices');
|
||||
});
|
||||
|
||||
test('route: throws on invalid waypoints values, waypoints must correspond with a coordinate index', function (assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(monaco_path);
|
||||
var options = {
|
||||
steps: true,
|
||||
coordinates: three_test_coordinates,
|
||||
waypoints: [0, 3, 2]
|
||||
};
|
||||
assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); },
|
||||
'Waypoints must correspond with the index of an input coordinate');
|
||||
});
|
||||
|
||||
test('route: throws on invalid waypoints values, waypoints must be an array', function (assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(monaco_path);
|
||||
var options = {
|
||||
steps: true,
|
||||
coordinates: three_test_coordinates,
|
||||
waypoints: "string"
|
||||
};
|
||||
assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); },
|
||||
'Waypoints must be an array of integers corresponding to the input coordinates.');
|
||||
});
|
||||
|
||||
test('route: throws on invalid waypoints values, waypoints must be an array of integers', function (assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(monaco_path);
|
||||
var options = {
|
||||
steps: true,
|
||||
coordinates: three_test_coordinates,
|
||||
waypoints: [0,1,"string"]
|
||||
};
|
||||
assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); },
|
||||
'Waypoint values must be an array of integers');
|
||||
});
|
||||
|
||||
test('route: throws on invalid waypoints values, waypoints must be an array of integers in increasing order', function (assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(monaco_path);
|
||||
var options = {
|
||||
steps: true,
|
||||
coordinates: three_test_coordinates.concat(three_test_coordinates),
|
||||
waypoints: [0,2,1,5]
|
||||
};
|
||||
assert.throws(function () { osrm.route(options, function (err, response) { console.error(`response: ${response}`); console.error(`error: ${err}`); }); },
|
||||
/Waypoints must be supplied in increasing order/);
|
||||
});
|
||||
|
||||
test('route: throws on invalid snapping values', function (assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(monaco_path);
|
||||
var options = {
|
||||
steps: true,
|
||||
coordinates: three_test_coordinates.concat(three_test_coordinates),
|
||||
snapping: "zing"
|
||||
};
|
||||
assert.throws(function () { osrm.route(options, function (err, response) { console.error(`response: ${response}`); console.error(`error: ${err}`); }); },
|
||||
/'snapping' param must be one of \[default, any\]/);
|
||||
});
|
||||
|
||||
test('route: snapping parameter passed through OK', function(assert) {
|
||||
assert.plan(2);
|
||||
var osrm = new OSRM(monaco_path);
|
||||
osrm.route({snapping: "any", coordinates: [[7.448205209414596,43.754001097311544],[7.447122039202185,43.75306156811368]]}, function(err, route) {
|
||||
assert.ifError(err);
|
||||
assert.equal(Math.round(route.routes[0].distance * 10), 1314); // Round it to nearest 0.1m to eliminate floating point comparison error
|
||||
});
|
||||
});
|
||||
@@ -284,7 +284,8 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
||||
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/,
|
||||
const Approach /*approach*/) const override
|
||||
const Approach /*approach*/,
|
||||
const bool /* use_all_edges */) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@@ -292,7 +293,8 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/,
|
||||
const double /*max_distance*/,
|
||||
const Approach /*approach*/) const override
|
||||
const Approach /*approach*/,
|
||||
const bool /* use_all_edges */) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@@ -302,7 +304,8 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
||||
const double /*max_distance*/,
|
||||
const int /*bearing*/,
|
||||
const int /*bearing_range*/,
|
||||
const Approach /*approach*/) const override
|
||||
const Approach /*approach*/,
|
||||
const bool /* use_all_edges */) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@@ -311,7 +314,8 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/,
|
||||
const int /*bearing*/,
|
||||
const int /*bearing_range*/,
|
||||
const Approach /*approach*/) const override
|
||||
const Approach /*approach*/,
|
||||
const bool /* use_all_edges */) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@@ -341,6 +345,7 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
||||
StringView GetDestinationsForID(const NameID /*id*/) const override { return StringView{}; }
|
||||
StringView GetExitsForID(const NameID /*id*/) const override { return StringView{}; }
|
||||
bool GetContinueStraightDefault() const override { return false; }
|
||||
std::string GetTimestamp() const override { return ""; }
|
||||
double GetMapMatchingMaxSpeed() const override { return 0; }
|
||||
const char *GetWeightName() const override { return ""; }
|
||||
unsigned GetWeightPrecision() const override { return 0; }
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "extractor/turn_lane_types.hpp"
|
||||
#include "guidance/turn_bearing.hpp"
|
||||
#include "guidance/turn_instruction.hpp"
|
||||
#include "guidance/turn_instruction.hpp"
|
||||
|
||||
#include "engine/algorithm.hpp"
|
||||
#include "engine/datafacade/algorithm_datafacade.hpp"
|
||||
@@ -54,6 +53,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
std::string GetTimestamp() const override { return ""; }
|
||||
NodeForwardRange GetUncompressedForwardGeometry(const EdgeID /* id */) const override
|
||||
{
|
||||
static NodeID data[] = {0, 1, 2, 3};
|
||||
@@ -167,39 +167,39 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
||||
}
|
||||
|
||||
std::pair<engine::PhantomNode, engine::PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::Coordinate /*input_coordinate*/,
|
||||
const engine::Approach /*approach*/) const override
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/,
|
||||
const engine::Approach /*approach*/,
|
||||
const bool /* use_all_edges */) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::pair<engine::PhantomNode, engine::PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::Coordinate /*input_coordinate*/,
|
||||
const double /*max_distance*/,
|
||||
const engine::Approach /*approach*/) const override
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/,
|
||||
const double /*max_distance*/,
|
||||
const engine::Approach /*approach*/,
|
||||
const bool /* use_all_edges */) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::pair<engine::PhantomNode, engine::PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::Coordinate /*input_coordinate*/,
|
||||
const double /*max_distance*/,
|
||||
const int /*bearing*/,
|
||||
const int /*bearing_range*/,
|
||||
const engine::Approach /*approach*/) const override
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/,
|
||||
const double /*max_distance*/,
|
||||
const int /*bearing*/,
|
||||
const int /*bearing_range*/,
|
||||
const engine::Approach /*approach*/,
|
||||
const bool /* use_all_edges */) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::pair<engine::PhantomNode, engine::PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::Coordinate /*input_coordinate*/,
|
||||
const int /*bearing*/,
|
||||
const int /*bearing_range*/,
|
||||
const engine::Approach /*approach*/) const override
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/,
|
||||
const int /*bearing*/,
|
||||
const int /*bearing_range*/,
|
||||
const engine::Approach /*approach*/,
|
||||
const bool /* use_all_edges */) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user