Compare commits

..

4 Commits

Author SHA1 Message Date
Daniel Patterson 67e99c9809 Fix swapped variables, new version. 2019-02-08 15:50:33 -08:00
Kevin Kreiser 05647adcc6 Add stoppage penalty - consider acceleration and braking time, which can dominate short route ETAs. 2019-02-08 15:32:26 -08:00
Daniel Patterson 6c37b71046 Actually expose snapping in node bindings. 2019-02-03 12:09:24 -08:00
Daniel Patterson cb2a46b8d9 Merge changes from c1eda57c13 - add snapping=any|default parameter. 2019-02-03 10:40:26 -08:00
48 changed files with 682 additions and 798 deletions
+2 -135
View File
@@ -13,6 +13,7 @@ notifications:
branches: branches:
only: only:
- master - master
- 5.21
# enable building tags # enable building tags
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/ - /^v\d+\.\d+(\.\d+)?(-\S*)?$/
@@ -36,10 +37,6 @@ env:
- ENABLE_NODE_BINDINGS=On - ENABLE_NODE_BINDINGS=On
- NODE="10" - NODE="10"
stages:
- core
- optional
matrix: matrix:
fast_finish: true fast_finish: true
@@ -47,14 +44,12 @@ matrix:
include: include:
# Debug Builds # Debug Builds
- stage: core - os: linux
os: linux
compiler: "format-taginfo-docs" compiler: "format-taginfo-docs"
env: NODE=10 env: NODE=10
sudo: false sudo: false
before_install: before_install:
install: install:
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
- source $NVM_DIR/nvm.sh - source $NVM_DIR/nvm.sh
- nvm install $NODE - nvm install $NODE
- nvm use $NODE - nvm use $NODE
@@ -281,135 +276,7 @@ matrix:
after_success: after_success:
- ./scripts/travis/publish.sh - ./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: before_install:
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
- source $NVM_DIR/nvm.sh - source $NVM_DIR/nvm.sh
- nvm install $NODE - nvm install $NODE
- nvm use $NODE - nvm use $NODE
-8
View File
@@ -1,11 +1,3 @@
# 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)
# 5.21.0 # 5.21.0
- Changes from 5.20.0 - Changes from 5.20.0
- Features: - Features:
+1 -1
View File
@@ -11,7 +11,7 @@ SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY "FALSE")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md") 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_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_PACKAGE_CONTACT "Project OSRM <info@project-osrm.org>")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.TXT") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENCE.TXT")
SET(CPACK_STRIP_FILES "TRUE") SET(CPACK_STRIP_FILES "TRUE")
file(GLOB_RECURSE ProfileGlob ${CMAKE_SOURCE_DIR}/profiles/*) file(GLOB_RECURSE ProfileGlob ${CMAKE_SOURCE_DIR}/profiles/*)
+10 -15
View File
@@ -1,14 +1,14 @@
FROM debian:stretch-slim as builder FROM debian:buster-slim as builder
ARG DOCKER_TAG ARG DOCKER_TAG
ARG BUILD_CONCURRENCY
RUN mkdir -p /src && mkdir -p /opt RUN mkdir -p /src && mkdir -p /opt
COPY . /src COPY . /src
WORKDIR /src WORKDIR /src
RUN NPROC=${BUILD_CONCURRENCY:-$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1)} && \ RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
apt-get update && \ apt-get update && \
apt-get -y --no-install-recommends install cmake make git gcc g++ libbz2-dev libxml2-dev \ apt-get -y --no-install-recommends install cmake make git gcc g++ libbz2-dev libstxxl-dev libstxxl1v5 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 && \ 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) && \
echo "Building OSRM ${DOCKER_TAG}" && \ echo "Building OSRM ${DOCKER_TAG}" && \
git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \ git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \
echo "Building OSRM gitsha $(cat /opt/OSRM_GITSHA)" && \ echo "Building OSRM gitsha $(cat /opt/OSRM_GITSHA)" && \
@@ -30,20 +30,15 @@ RUN NPROC=${BUILD_CONCURRENCY:-$(grep -c ^processor /proc/cpuinfo 2>/dev/null ||
# 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/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) # Only the content below ends up in the image, this helps remove /src from the image (which is large)
FROM debian:stretch-slim as runstage FROM debian:buster-slim as runstage
RUN mkdir -p /src && mkdir -p /opt RUN mkdir -p /src && mkdir -p /opt
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y --no-install-recommends libboost-program-options1.62.0 libboost-regex1.62.0 \ apt-get install -y --no-install-recommends libboost-program-options1.67.0 libboost-regex1.67.0 \
libboost-date-time1.62.0 libboost-chrono1.62.0 libboost-filesystem1.62.0 \ libboost-date-time1.67.0 libboost-chrono1.67.0 libboost-filesystem1.67.0 \
libboost-iostreams1.62.0 libboost-thread1.62.0 expat liblua5.2-0 libtbb2 &&\ libboost-iostreams1.67.0 libboost-thread1.67.0 expat liblua5.2-0 libtbb2 &&\
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
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 /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 WORKDIR /opt
EXPOSE 5000 EXPOSE 5000
+1 -1
View File
@@ -6,4 +6,4 @@
# ensure that "COPY . /src" is referring to the repo root, not the directory # ensure that "COPY . /src" is referring to the repo root, not the directory
# that contains the Dockerfile. # that contains the Dockerfile.
# This script gets executed with a pwd of wherever the Dockerfile is. # This script gets executed with a pwd of wherever the Dockerfile is.
docker build --build-arg BUILD_CONCURRENCY=${CONCURRENCY:-1} --build-arg DOCKER_TAG=${DOCKER_TAG} -t $IMAGE_NAME -f Dockerfile .. docker build --build-arg DOCKER_TAG=${DOCKER_TAG} -t $IMAGE_NAME -f Dockerfile ..
+1 -9
View File
@@ -70,8 +70,6 @@ curl 'http://router.project-osrm.org/route/v1/driving/polyline(ofp_Ik_vpAilAyu@t
### Responses ### Responses
#### Code
Every response object has a `code` property containing one of the strings below or a service dependent code: Every response object has a `code` property containing one of the strings below or a service dependent code:
| Type | Description | | Type | Description |
@@ -89,17 +87,12 @@ 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. - `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`. - 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 #### Example response
```json ```json
{ {
"code": "Ok", "code": "Ok",
"message": "Everything worked", "message": "Everything worked"
"data_version": "2017-11-17T21:43:02Z"
} }
``` ```
@@ -202,7 +195,6 @@ 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) | |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.| |overview |`simplified` (default), `full`, `false` |Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all.|
|continue\_straight |`default` (default), `true`, `false` |Forces the route to keep going straight at waypoints constraining uturns there even if it would be faster. Default value depends on the profile. | |continue\_straight |`default` (default), `true`, `false` |Forces the route to keep going straight at waypoints constraining uturns there even if it would be faster. Default value depends on the profile. |
|waypoints | `{index};{index};{index}...` |Treats input coordinates indicated by given indices as waypoints in returned Match object. Default is to treat all input coordinates as waypoints. |
\* Please note that even if alternative routes are requested, a result cannot be guaranteed. \* Please note that even if alternative routes are requested, a result cannot be guaranteed.
-2
View File
@@ -57,7 +57,6 @@ 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.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.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.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` `null`/`true`/`false`
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
@@ -211,7 +210,6 @@ 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.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.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.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.
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
**Examples** **Examples**
+36
View File
@@ -0,0 +1,36 @@
@routing @maxspeed @car
Feature: Car - Acceleration profiles
Background: Use specific speeds
Given the profile "car"
Given a grid size of 1000 meters
Scenario: Car - Use stoppage penalty at waypoints
Given the node map
"""
a 1 2 3 4 5 b
"""
And the ways
| nodes | highway | maxspeed:forward | maxspeed:backward |
| ab | trunk | 60 | 45 |
And the query options
| stoppage_penalty | 5,100 |
When I route I should get
| from | to | route | time |
| a | b | ab,ab | 481.1s |
When I route I should get
| from | to | route | time |
| b | a | ab,ab | 609.9s |
When I route I should get
| from | to | route | time |
| a | a | ab,ab | 0s |
When I request a travel time matrix I should get
| | a | b |
| a | 0 | 481.1 |
| b | 609.9 | 0 |
-4
View File
@@ -75,10 +75,6 @@ module.exports = function () {
got.message = json.message || ''; got.message = json.message || '';
} }
if (headers.has('data_version')) {
got.data_version = json.data_version || '';
}
if (headers.has('#')) { if (headers.has('#')) {
// comment column // comment column
got['#'] = row['#']; got['#'] = row['#'];
+3 -20
View File
@@ -17,26 +17,9 @@ Feature: Basic Routing
| ab | | ab |
When I route I should get When I route I should get
| from | to | route | data_version | | from | to | route |
| a | b | ab,ab | | | a | b | ab,ab |
| b | a | 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 Scenario: Routing in between two nodes of way
Given the node map Given the node map
+36
View File
@@ -0,0 +1,36 @@
@routing @maxspeed @testbot
Feature: Testbot - Acceleration profiles
Background: Use specific speeds
Given the profile "testbot"
Given a grid size of 1000 meters
Scenario: Testbot - Use stoppage penalty at waypoints
Given the node map
"""
a 1 2 3 4 5 b
"""
And the ways
| nodes | highway | maxspeed:forward | maxspeed:backward |
| ab | trunk | 60 | 45 |
And the query options
| stoppage_penalty | 5,100 |
When I route I should get
| from | to | route | time |
| a | b | ab,ab | 412.3s |
When I route I should get
| from | to | route | time |
| b | a | ab,ab | 505.9s |
When I route I should get
| from | to | route | time |
| a | a | ab,ab | 0s |
When I request a travel time matrix I should get
| | a | b |
| a | 0 | 412.3 |
| b | 505.9 | 0 |
-47
View File
@@ -18,53 +18,6 @@ Feature: Via points
| waypoints | route | | waypoints | route |
| a,b,c | abc,abc,abc,abc | | 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 Scenario: Simple via point with core factor
Given the contract extra arguments "--core 0.8" Given the contract extra arguments "--core 0.8"
Given the node map Given the node map
+11 -2
View File
@@ -81,6 +81,8 @@ struct BaseParameters
bool generate_hints = true; bool generate_hints = true;
SnappingType snapping = SnappingType::Default; SnappingType snapping = SnappingType::Default;
double min_stoppage_penalty = INVALID_MINIMUM_STOPPAGE_PENALTY;
double max_stoppage_penalty = INVALID_MAXIMUM_STOPPAGE_PENALTY;
BaseParameters(const std::vector<util::Coordinate> coordinates_ = {}, BaseParameters(const std::vector<util::Coordinate> coordinates_ = {},
const std::vector<boost::optional<Hint>> hints_ = {}, const std::vector<boost::optional<Hint>> hints_ = {},
@@ -89,16 +91,23 @@ struct BaseParameters
std::vector<boost::optional<Approach>> approaches_ = {}, std::vector<boost::optional<Approach>> approaches_ = {},
bool generate_hints_ = true, bool generate_hints_ = true,
std::vector<std::string> exclude = {}, std::vector<std::string> exclude = {},
const SnappingType snapping_ = SnappingType::Default) const SnappingType snapping_ = SnappingType::Default,
double min_stoppage_penalty_ = INVALID_MINIMUM_STOPPAGE_PENALTY,
double max_stoppage_penalty_ = INVALID_MAXIMUM_STOPPAGE_PENALTY)
: coordinates(coordinates_), hints(hints_), radiuses(radiuses_), bearings(bearings_), : 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_) snapping(snapping_), min_stoppage_penalty(min_stoppage_penalty_),
max_stoppage_penalty(max_stoppage_penalty_)
{ {
} }
// FIXME add validation for invalid bearing values // FIXME add validation for invalid bearing values
bool IsValid() const bool IsValid() const
{ {
if (min_stoppage_penalty <= 0 || max_stoppage_penalty <= 0 ||
min_stoppage_penalty > max_stoppage_penalty)
return false;
return (hints.empty() || hints.size() == coordinates.size()) && return (hints.empty() || hints.size() == coordinates.size()) &&
(bearings.empty() || bearings.size() == coordinates.size()) && (bearings.empty() || bearings.size() == coordinates.size()) &&
(radiuses.empty() || radiuses.size() == coordinates.size()) && (radiuses.empty() || radiuses.size() == coordinates.size()) &&
+9 -4
View File
@@ -63,7 +63,7 @@ struct MatchParameters : public RouteParameters
RouteParameters::GeometriesType::Polyline, RouteParameters::GeometriesType::Polyline,
RouteParameters::OverviewType::Simplified, RouteParameters::OverviewType::Simplified,
{}), {}),
gaps(GapsType::Split), tidy(false) gaps(GapsType::Split), tidy(false), waypoints()
{ {
} }
@@ -79,19 +79,24 @@ struct MatchParameters : public RouteParameters
bool tidy_, bool tidy_,
std::vector<std::size_t> waypoints_, std::vector<std::size_t> waypoints_,
Args... args_) Args... args_)
: RouteParameters{std::forward<Args>(args_)..., waypoints_}, : RouteParameters{std::forward<Args>(args_)...}, timestamps{std::move(timestamps_)},
timestamps{std::move(timestamps_)}, gaps(gaps_), tidy(tidy_) gaps(gaps_), tidy(tidy_), waypoints{std::move(waypoints_)}
{ {
} }
std::vector<unsigned> timestamps; std::vector<unsigned> timestamps;
GapsType gaps; GapsType gaps;
bool tidy; bool tidy;
std::vector<std::size_t> waypoints;
bool IsValid() const 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() && return RouteParameters::IsValid() &&
(timestamps.empty() || timestamps.size() == coordinates.size()); (timestamps.empty() || timestamps.size() == coordinates.size()) && valid_waypoints;
} }
}; };
} }
+4 -11
View File
@@ -44,11 +44,8 @@ class RouteAPI : public BaseAPI
{ {
} }
void void MakeResponse(const InternalManyRoutesResult &raw_routes,
MakeResponse(const InternalManyRoutesResult &raw_routes, util::json::Object &response) const
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()); BOOST_ASSERT(!raw_routes.routes.empty());
@@ -65,14 +62,10 @@ class RouteAPI : public BaseAPI
route.target_traversed_in_reverse)); route.target_traversed_in_reverse));
} }
response.values["waypoints"] = BaseAPI::MakeWaypoints(all_start_end_points); response.values["waypoints"] =
BaseAPI::MakeWaypoints(raw_routes.routes[0].segment_end_coordinates);
response.values["routes"] = std::move(jsRoutes); response.values["routes"] = std::move(jsRoutes);
response.values["code"] = "Ok"; response.values["code"] = "Ok";
auto data_timestamp = facade.GetTimestamp();
if (!data_timestamp.empty())
{
response.values["data_version"] = data_timestamp;
}
} }
protected: protected:
+7 -51
View File
@@ -98,8 +98,7 @@ struct RouteParameters : public BaseParameters
annotations_type{AnnotationsType::None}, annotations_type{AnnotationsType::None},
geometries{geometries_}, geometries{geometries_},
overview{overview_}, overview{overview_},
continue_straight{continue_straight_}, continue_straight{continue_straight_}
waypoints()
{ {
} }
@@ -115,9 +114,7 @@ struct RouteParameters : public BaseParameters
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_}, : BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_}, number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_},
annotations_type{annotations_ ? AnnotationsType::All : AnnotationsType::None}, annotations_type{annotations_ ? AnnotationsType::All : AnnotationsType::None},
geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_}, geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_}
waypoints()
{ {
} }
@@ -134,43 +131,7 @@ struct RouteParameters : public BaseParameters
number_of_alternatives{alternatives_ ? 1u : 0u}, number_of_alternatives{alternatives_ ? 1u : 0u},
annotations{annotations_ == AnnotationsType::None ? false : true}, annotations{annotations_ == AnnotationsType::None ? false : true},
annotations_type{annotations_}, geometries{geometries_}, overview{overview_}, annotations_type{annotations_}, geometries{geometries_}, overview{overview_},
continue_straight{continue_straight_}, waypoints() continue_straight{continue_straight_}
{
}
// 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_}
{ {
} }
@@ -183,17 +144,12 @@ struct RouteParameters : public BaseParameters
GeometriesType geometries = GeometriesType::Polyline; GeometriesType geometries = GeometriesType::Polyline;
OverviewType overview = OverviewType::Simplified; OverviewType overview = OverviewType::Simplified;
boost::optional<bool> continue_straight; boost::optional<bool> continue_straight;
std::vector<std::size_t> waypoints;
bool IsValid() const bool IsValid() const
{ {
const auto coordinates_ok = coordinates.size() >= 2; const auto coordinates_ok = coordinates.size() >= 2;
const auto base_params_ok = BaseParameters::IsValid(); const auto base_params_ok = BaseParameters::IsValid();
const auto valid_waypoints = return coordinates_ok && base_params_ok;
std::all_of(waypoints.begin(), waypoints.end(), [this](const auto &w) {
return w < coordinates.size();
});
return coordinates_ok && base_params_ok && valid_waypoints;
} }
}; };
@@ -217,8 +173,8 @@ inline RouteParameters::AnnotationsType operator|=(RouteParameters::AnnotationsT
{ {
return lhs = lhs | rhs; return lhs = lhs | rhs;
} }
} // ns api }
} // ns engine }
} // ns osrm }
#endif #endif
+3 -5
View File
@@ -78,7 +78,6 @@ struct TableParameters : public BaseParameters
}; };
AnnotationsType annotations = AnnotationsType::Duration; AnnotationsType annotations = AnnotationsType::Duration;
double scale_factor = 1; double scale_factor = 1;
TableParameters() = default; TableParameters() = default;
@@ -113,7 +112,6 @@ struct TableParameters : public BaseParameters
destinations{std::move(destinations_)}, fallback_speed{fallback_speed_}, destinations{std::move(destinations_)}, fallback_speed{fallback_speed_},
fallback_coordinate_type{fallback_coordinate_type_}, annotations{annotations_}, fallback_coordinate_type{fallback_coordinate_type_}, annotations{annotations_},
scale_factor{scale_factor_} scale_factor{scale_factor_}
{ {
} }
@@ -166,8 +164,8 @@ inline TableParameters::AnnotationsType &operator|=(TableParameters::Annotations
{ {
return lhs = lhs | rhs; return lhs = lhs | rhs;
} }
} } // namespace api
} } // namespace engine
} } // namespace osrm
#endif // ENGINE_API_TABLE_PARAMETERS_HPP #endif // ENGINE_API_TABLE_PARAMETERS_HPP
@@ -137,7 +137,6 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
extractor::Datasources *m_datasources; extractor::Datasources *m_datasources;
std::uint32_t m_check_sum; std::uint32_t m_check_sum;
StringView m_data_timestamp;
util::vector_view<util::Coordinate> m_coordinate_list; util::vector_view<util::Coordinate> m_coordinate_list;
extractor::PackedOSMIDsView m_osmnodeid_list; extractor::PackedOSMIDsView m_osmnodeid_list;
util::vector_view<std::uint32_t> m_lane_description_offsets; util::vector_view<std::uint32_t> m_lane_description_offsets;
@@ -184,8 +183,6 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
m_check_sum = *index.GetBlockPtr<std::uint32_t>("/common/connectivity_checksum"); 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) = std::tie(m_coordinate_list, m_osmnodeid_list) =
make_nbn_data_view(index, "/common/nbn_data"); make_nbn_data_view(index, "/common/nbn_data");
@@ -387,63 +384,88 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
input_coordinate, max_results, max_distance, bearing, bearing_range, approach); input_coordinate, max_results, max_distance, bearing, bearing_range, approach);
} }
std::pair<PhantomNode, PhantomNode> std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const util::Coordinate input_coordinate,
const Approach approach, const Approach approach,
const bool use_all_edges) const override final const bool use_all_edges,
const double minimum_stoppage_penalty,
const double maximum_stoppage_penalty) const override final
{ {
BOOST_ASSERT(m_geospatial_query.get()); BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
input_coordinate, approach, use_all_edges); input_coordinate,
approach,
use_all_edges,
minimum_stoppage_penalty,
maximum_stoppage_penalty);
} }
std::pair<PhantomNode, PhantomNode> std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const util::Coordinate input_coordinate,
const double max_distance, const double max_distance,
const Approach approach, const Approach approach,
const bool use_all_edges) const override final const bool use_all_edges,
const double minimum_stoppage_penalty,
const double maximum_stoppage_penalty) const override final
{ {
BOOST_ASSERT(m_geospatial_query.get()); BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
input_coordinate, max_distance, approach, use_all_edges); input_coordinate,
max_distance,
approach,
use_all_edges,
minimum_stoppage_penalty,
maximum_stoppage_penalty);
} }
std::pair<PhantomNode, PhantomNode> std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const util::Coordinate input_coordinate,
const double max_distance, const double max_distance,
const int bearing, const int bearing,
const int bearing_range, const int bearing_range,
const Approach approach, const Approach approach,
const bool use_all_edges) const override final const bool use_all_edges,
const double minimum_stoppage_penalty,
const double maximum_stoppage_penalty) const override final
{ {
BOOST_ASSERT(m_geospatial_query.get()); BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
input_coordinate, max_distance, bearing, bearing_range, approach, use_all_edges); input_coordinate,
max_distance,
bearing,
bearing_range,
approach,
use_all_edges,
minimum_stoppage_penalty,
maximum_stoppage_penalty);
} }
std::pair<PhantomNode, PhantomNode> std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const util::Coordinate input_coordinate,
const int bearing, const int bearing,
const int bearing_range, const int bearing_range,
const Approach approach, const Approach approach,
const bool use_all_edges) const override final const bool use_all_edges,
const double minimum_stoppage_penalty,
const double maximum_stoppage_penalty) const override final
{ {
BOOST_ASSERT(m_geospatial_query.get()); BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
input_coordinate, bearing, bearing_range, approach, use_all_edges); input_coordinate,
bearing,
bearing_range,
approach,
use_all_edges,
minimum_stoppage_penalty,
maximum_stoppage_penalty);
} }
std::uint32_t GetCheckSum() const override final { return m_check_sum; } 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 GeometryID GetGeometryIndex(const NodeID id) const override final
{ {
return edge_based_node_data.GetGeometryID(id); return edge_based_node_data.GetGeometryID(id);
+30 -24
View File
@@ -74,8 +74,6 @@ class BaseDataFacade
virtual std::uint32_t GetCheckSum() const = 0; virtual std::uint32_t GetCheckSum() const = 0;
virtual std::string GetTimestamp() const = 0;
// node and edge information access // node and edge information access
virtual util::Coordinate GetCoordinateOfNode(const NodeID id) const = 0; virtual util::Coordinate GetCoordinateOfNode(const NodeID id) const = 0;
@@ -159,28 +157,36 @@ class BaseDataFacade
const double max_distance, const double max_distance,
const Approach approach) const = 0; const Approach approach) const = 0;
virtual std::pair<PhantomNode, PhantomNode> virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const util::Coordinate input_coordinate,
const Approach approach, const Approach approach,
const bool use_all_edges) const = 0; const bool use_all_edges,
virtual std::pair<PhantomNode, PhantomNode> const double minimum_stoppage_penalty,
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const double maximum_stoppage_penalty) const = 0;
const double max_distance, virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const Approach approach, const util::Coordinate input_coordinate,
const bool use_all_edges) const = 0; const double max_distance,
virtual std::pair<PhantomNode, PhantomNode> const Approach approach,
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const bool use_all_edges,
const double max_distance, const double minimum_stoppage_penalty,
const int bearing, const double maximum_stoppage_penalty) const = 0;
const int bearing_range, virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const Approach approach, const util::Coordinate input_coordinate,
const bool use_all_edges) const = 0; const double max_distance,
virtual std::pair<PhantomNode, PhantomNode> const int bearing,
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const int bearing_range,
const int bearing, const Approach approach,
const int bearing_range, const bool use_all_edges,
const Approach approach, const double minimum_stoppage_penalty,
const bool use_all_edges = false) const = 0; const double maximum_stoppage_penalty) const = 0;
virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const util::Coordinate input_coordinate,
const int bearing,
const int bearing_range,
const Approach approach,
const bool use_all_edges,
const double minimum_stoppage_penalty,
const double maximum_stoppage_penalty) const = 0;
virtual bool HasLaneData(const EdgeID id) const = 0; virtual bool HasLaneData(const EdgeID id) const = 0;
virtual util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const = 0; virtual util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const = 0;
+113 -35
View File
@@ -206,7 +206,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance, const double max_distance,
const Approach approach, const Approach approach,
const bool use_all_edges) const const bool use_all_edges,
const double min_stoppage_penalty,
const double max_stoppage_penalty) const
{ {
bool has_small_component = false; bool has_small_component = false;
bool has_big_component = false; bool has_big_component = false;
@@ -248,8 +250,13 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
} }
BOOST_ASSERT(results.size() == 1 || results.size() == 2); BOOST_ASSERT(results.size() == 1 || results.size() == 2);
return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node, return std::make_pair(
MakePhantomNode(input_coordinate, results.back()).phantom_node); MakePhantomNode(
input_coordinate, results.front(), min_stoppage_penalty, max_stoppage_penalty)
.phantom_node,
MakePhantomNode(
input_coordinate, results.back(), min_stoppage_penalty, max_stoppage_penalty)
.phantom_node);
} }
// Returns the nearest phantom node. If this phantom node is not from a big component // Returns the nearest phantom node. If this phantom node is not from a big component
@@ -257,7 +264,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
std::pair<PhantomNode, PhantomNode> std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const Approach approach, const Approach approach,
const bool use_all_edges) const const bool use_all_edges,
const double min_stoppage_penalty,
const double max_stoppage_penalty) const
{ {
bool has_small_component = false; bool has_small_component = false;
bool has_big_component = false; bool has_big_component = false;
@@ -298,8 +307,13 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
} }
BOOST_ASSERT(results.size() == 1 || results.size() == 2); BOOST_ASSERT(results.size() == 1 || results.size() == 2);
return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node, return std::make_pair(
MakePhantomNode(input_coordinate, results.back()).phantom_node); MakePhantomNode(
input_coordinate, results.front(), min_stoppage_penalty, max_stoppage_penalty)
.phantom_node,
MakePhantomNode(
input_coordinate, results.back(), min_stoppage_penalty, max_stoppage_penalty)
.phantom_node);
} }
// Returns the nearest phantom node. If this phantom node is not from a big component // Returns the nearest phantom node. If this phantom node is not from a big component
@@ -309,7 +323,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
const int bearing, const int bearing,
const int bearing_range, const int bearing_range,
const Approach approach, const Approach approach,
const bool use_all_edges) const const bool use_all_edges,
const double min_stoppage_penalty,
const double max_stoppage_penalty) const
{ {
bool has_small_component = false; bool has_small_component = false;
bool has_big_component = false; bool has_big_component = false;
@@ -357,8 +373,13 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
} }
BOOST_ASSERT(results.size() > 0); BOOST_ASSERT(results.size() > 0);
return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node, return std::make_pair(
MakePhantomNode(input_coordinate, results.back()).phantom_node); MakePhantomNode(
input_coordinate, results.front(), min_stoppage_penalty, max_stoppage_penalty)
.phantom_node,
MakePhantomNode(
input_coordinate, results.back(), min_stoppage_penalty, max_stoppage_penalty)
.phantom_node);
} }
// Returns the nearest phantom node. If this phantom node is not from a big component // Returns the nearest phantom node. If this phantom node is not from a big component
@@ -369,7 +390,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
const int bearing, const int bearing,
const int bearing_range, const int bearing_range,
const Approach approach, const Approach approach,
const bool use_all_edges) const const bool use_all_edges,
const double min_stoppage_penalty,
const double max_stoppage_penalty) const
{ {
bool has_small_component = false; bool has_small_component = false;
bool has_big_component = false; bool has_big_component = false;
@@ -419,8 +442,13 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
} }
BOOST_ASSERT(results.size() > 0); BOOST_ASSERT(results.size() > 0);
return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node, return std::make_pair(
MakePhantomNode(input_coordinate, results.back()).phantom_node); MakePhantomNode(
input_coordinate, results.front(), min_stoppage_penalty, max_stoppage_penalty)
.phantom_node,
MakePhantomNode(
input_coordinate, results.back(), min_stoppage_penalty, max_stoppage_penalty)
.phantom_node);
} }
private: private:
@@ -439,7 +467,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
} }
PhantomNodeWithDistance MakePhantomNode(const util::Coordinate input_coordinate, PhantomNodeWithDistance MakePhantomNode(const util::Coordinate input_coordinate,
const EdgeData &data) const const EdgeData &data,
const double min_stoppage_penalty = 0,
const double max_stoppage_penalty = 0) const
{ {
util::Coordinate point_on_segment; util::Coordinate point_on_segment;
double ratio; double ratio;
@@ -478,16 +508,21 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
forward_durations.begin() + data.fwd_segment_position, forward_durations.begin() + data.fwd_segment_position,
EdgeDuration{0}); EdgeDuration{0});
EdgeDistance forward_distance_offset = 0; // For measuring distance from begin up to end
// Sum up the distance from the start to the fwd_segment_position const auto appx_distance = [this](decltype(forward_geometry.begin()) begin,
for (auto current = forward_geometry.begin(); decltype(forward_geometry.begin()) end) {
current < forward_geometry.begin() + data.fwd_segment_position; EdgeDistance dist = 0;
++current) for (; begin != end; ++begin)
{ {
forward_distance_offset += util::coordinate_calculation::fccApproximateDistance( dist += util::coordinate_calculation::fccApproximateDistance(
datafacade.GetCoordinateOfNode(*current), datafacade.GetCoordinateOfNode(*begin),
datafacade.GetCoordinateOfNode(*std::next(current))); datafacade.GetCoordinateOfNode(*std::next(begin)));
} }
return dist;
};
EdgeDistance forward_distance_offset = appx_distance(
forward_geometry.begin(), forward_geometry.begin() + data.fwd_segment_position);
BOOST_ASSERT(data.fwd_segment_position < BOOST_ASSERT(data.fwd_segment_position <
std::distance(forward_durations.begin(), forward_durations.end())); std::distance(forward_durations.begin(), forward_durations.end()));
@@ -508,16 +543,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
reverse_durations.end() - data.fwd_segment_position - 1, reverse_durations.end() - data.fwd_segment_position - 1,
EdgeDuration{0}); EdgeDuration{0});
EdgeDistance reverse_distance_offset = 0; EdgeDistance reverse_distance_offset =
// Sum up the distance from just after the fwd_segment_position to the end appx_distance(forward_geometry.begin() + data.fwd_segment_position + 1,
for (auto current = forward_geometry.begin() + data.fwd_segment_position + 1; std::prev(forward_geometry.end()));
current != std::prev(forward_geometry.end());
++current)
{
reverse_distance_offset += util::coordinate_calculation::fccApproximateDistance(
datafacade.GetCoordinateOfNode(*current),
datafacade.GetCoordinateOfNode(*std::next(current)));
}
EdgeWeight reverse_weight = EdgeWeight reverse_weight =
reverse_weights[reverse_weights.size() - data.fwd_segment_position - 1]; reverse_weights[reverse_weights.size() - data.fwd_segment_position - 1];
@@ -527,16 +555,64 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
point_on_segment, point_on_segment,
datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position + 1))); datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position + 1)));
// where does this speed lie with respect to the min/max penalizable speeds
auto penalty_range = min_stoppage_penalty != INVALID_MINIMUM_STOPPAGE_PENALTY &&
max_stoppage_penalty != INVALID_MAXIMUM_STOPPAGE_PENALTY
? max_stoppage_penalty - min_stoppage_penalty
: 0;
auto stoppage_penalty =
[penalty_range, min_stoppage_penalty, max_stoppage_penalty](double speed) -> double {
// You're so slow already you don't get a penalty
if (speed < MINIMAL_ACCEL_DECEL_PENALIZABLE_SPEED)
return 0;
// Find where it is on the scale
constexpr auto max =
MAXIMAL_ACCEL_DECEL_PENALIZABLE_SPEED - MINIMAL_ACCEL_DECEL_PENALIZABLE_SPEED;
auto ratio = (speed - MINIMAL_ACCEL_DECEL_PENALIZABLE_SPEED) / max;
// You're faster than the max so you get the max
if (ratio >= 1)
return max_stoppage_penalty;
// You're in between so you get a linear combination
return min_stoppage_penalty + ratio * penalty_range;
};
// We may end up adding a stoppage penalty
EdgeDuration forward_stoppage_penalty = 0;
EdgeDuration reverse_stoppage_penalty = 0;
auto total_distance = penalty_range > 0 ? appx_distance(forward_geometry.begin(),
std::prev(forward_geometry.end()))
: 0.0;
ratio = std::min(1.0, std::max(0.0, ratio)); ratio = std::min(1.0, std::max(0.0, ratio));
if (data.forward_segment_id.id != SPECIAL_SEGMENTID) if (data.forward_segment_id.id != SPECIAL_SEGMENTID)
{ {
forward_weight = static_cast<EdgeWeight>(forward_weight * ratio); forward_weight = static_cast<EdgeWeight>(forward_weight * ratio);
forward_duration = static_cast<EdgeDuration>(forward_duration * ratio); forward_duration = static_cast<EdgeDuration>(forward_duration * ratio);
// Stoppage penalty based on speed
if (data.forward_segment_id.enabled && penalty_range > 0)
{
const auto total_duration = std::accumulate(
forward_durations.begin(), forward_durations.end(), EdgeDuration{0});
const auto speed = total_distance / (total_duration * 0.1);
forward_stoppage_penalty =
static_cast<EdgeDuration>((stoppage_penalty(speed) * 10) + .5);
}
} }
if (data.reverse_segment_id.id != SPECIAL_SEGMENTID) if (data.reverse_segment_id.id != SPECIAL_SEGMENTID)
{ {
reverse_weight -= static_cast<EdgeWeight>(reverse_weight * ratio); reverse_weight -= static_cast<EdgeWeight>(reverse_weight * ratio);
reverse_duration -= static_cast<EdgeDuration>(reverse_duration * ratio); reverse_duration -= static_cast<EdgeDuration>(reverse_duration * ratio);
// Stoppage penalty based on speed
if (data.reverse_segment_id.enabled && penalty_range > 0)
{
const auto total_duration = std::accumulate(
reverse_durations.begin(), reverse_durations.end(), EdgeDuration{0});
const auto speed = total_distance / (total_duration * 0.1);
reverse_stoppage_penalty =
static_cast<EdgeDuration>((stoppage_penalty(speed) * 10) + .5);
}
} }
// check phantom node segments validity // check phantom node segments validity
@@ -567,6 +643,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
reverse_duration, reverse_duration,
forward_duration_offset, forward_duration_offset,
reverse_duration_offset, reverse_duration_offset,
forward_stoppage_penalty,
reverse_stoppage_penalty,
is_forward_valid_source, is_forward_valid_source,
is_forward_valid_target, is_forward_valid_target,
is_reverse_valid_source, is_reverse_valid_source,
@@ -717,7 +795,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
const CoordinateList &coordinates; const CoordinateList &coordinates;
DataFacadeT &datafacade; DataFacadeT &datafacade;
}; };
} } // namespace engine
} } // namespace osrm
#endif #endif
+9 -2
View File
@@ -122,7 +122,7 @@ std::array<std::uint32_t, SegmentNumber> summarizeRoute(const datafacade::BaseDa
[](const NamedSegment &segment) { return segment.name_id; }); [](const NamedSegment &segment) { return segment.name_id; });
return summary; return summary;
} }
} } // namespace detail
inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade, inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
const std::vector<PathData> &route_data, const std::vector<PathData> &route_data,
@@ -166,7 +166,7 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
// `forward_duration`: duration of (d,t) // `forward_duration`: duration of (d,t)
// `forward_offset`: duration of (c, d) // `forward_offset`: duration of (c, d)
// path_data will have entries for (s,b), (b, c), (c, d) but (d, t) is only // path_data will have entries for (s,b), (b, c), (c, d) but (d, t) is only
// caputed by the phantom node. So we need to add the target duration here. // captured by the phantom node. So we need to add the target duration here.
// On local segments, the target duration is already part of the duration, however. // On local segments, the target duration is already part of the duration, however.
duration = duration + target_duration; duration = duration + target_duration;
@@ -182,6 +182,13 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
duration = std::max(0, duration); duration = std::max(0, duration);
} }
// Add start and stop penalties
if (distance > 0)
duration +=
(target_traversed_in_reverse
? source_node.reverse_duration_penalty + target_node.reverse_duration_penalty
: source_node.forward_duration_penalty + target_node.forward_duration_penalty);
std::string summary; std::string summary;
if (needs_summary) if (needs_summary)
{ {
+4 -4
View File
@@ -63,11 +63,11 @@ struct Hint
friend std::ostream &operator<<(std::ostream &, const Hint &); friend std::ostream &operator<<(std::ostream &, const Hint &);
}; };
static_assert(sizeof(Hint) == 80 + 4, "Hint is bigger than expected"); static_assert(sizeof(Hint) == sizeof(PhantomNode) + 4, "Hint is bigger than expected");
constexpr std::size_t ENCODED_HINT_SIZE = 112; constexpr std::size_t ENCODED_HINT_SIZE = 124;
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint), static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint),
"ENCODED_HINT_SIZE does not match size of Hint"); "ENCODED_HINT_SIZE does not match size of Hint");
} } // namespace engine
} } // namespace osrm
#endif #endif
+24 -16
View File
@@ -50,9 +50,10 @@ struct PhantomNode
forward_distance(INVALID_EDGE_DISTANCE), reverse_distance(INVALID_EDGE_DISTANCE), forward_distance(INVALID_EDGE_DISTANCE), reverse_distance(INVALID_EDGE_DISTANCE),
forward_distance_offset(0), reverse_distance_offset(0), forward_distance_offset(0), reverse_distance_offset(0),
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION), forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
forward_duration_offset(0), reverse_duration_offset(0), fwd_segment_position(0), forward_duration_offset(0), reverse_duration_offset(0), forward_duration_penalty(0),
is_valid_forward_source{false}, is_valid_forward_target{false}, reverse_duration_penalty(0), fwd_segment_position(0), is_valid_forward_source{false},
is_valid_reverse_source{false}, is_valid_reverse_target{false}, bearing(0) is_valid_forward_target{false}, is_valid_reverse_source{false},
is_valid_reverse_target{false}, bearing(0)
{ {
} }
@@ -69,13 +70,13 @@ struct PhantomNode
return reverse_weight_offset + reverse_weight; return reverse_weight_offset + reverse_weight;
} }
EdgeWeight GetForwardDuration() const EdgeDuration GetForwardDuration() const
{ {
BOOST_ASSERT(forward_segment_id.enabled); BOOST_ASSERT(forward_segment_id.enabled);
return forward_duration + forward_duration_offset; return forward_duration + forward_duration_offset;
} }
EdgeWeight GetReverseDuration() const EdgeDuration GetReverseDuration() const
{ {
BOOST_ASSERT(reverse_segment_id.enabled); BOOST_ASSERT(reverse_segment_id.enabled);
return reverse_duration + reverse_duration_offset; return reverse_duration + reverse_duration_offset;
@@ -163,10 +164,12 @@ struct PhantomNode
EdgeDistance reverse_distance, EdgeDistance reverse_distance,
EdgeDistance forward_distance_offset, EdgeDistance forward_distance_offset,
EdgeDistance reverse_distance_offset, EdgeDistance reverse_distance_offset,
EdgeWeight forward_duration, EdgeDuration forward_duration,
EdgeWeight reverse_duration, EdgeDuration reverse_duration,
EdgeWeight forward_duration_offset, EdgeDuration forward_duration_offset,
EdgeWeight reverse_duration_offset, EdgeDuration reverse_duration_offset,
EdgeDuration forward_duration_penalty,
EdgeDuration reverse_duration_penalty,
bool is_valid_forward_source, bool is_valid_forward_source,
bool is_valid_forward_target, bool is_valid_forward_target,
bool is_valid_reverse_source, bool is_valid_reverse_source,
@@ -182,6 +185,8 @@ struct PhantomNode
reverse_distance_offset{reverse_distance_offset}, forward_duration{forward_duration}, reverse_distance_offset{reverse_distance_offset}, forward_duration{forward_duration},
reverse_duration{reverse_duration}, forward_duration_offset{forward_duration_offset}, reverse_duration{reverse_duration}, forward_duration_offset{forward_duration_offset},
reverse_duration_offset{reverse_duration_offset}, reverse_duration_offset{reverse_duration_offset},
forward_duration_penalty{forward_duration_penalty},
reverse_duration_penalty{reverse_duration_penalty},
component{component.id, component.is_tiny}, location{location}, component{component.id, component.is_tiny}, location{location},
input_location{input_location}, fwd_segment_position{other.fwd_segment_position}, input_location{input_location}, fwd_segment_position{other.fwd_segment_position},
is_valid_forward_source{is_valid_forward_source}, is_valid_forward_source{is_valid_forward_source},
@@ -201,10 +206,13 @@ struct PhantomNode
EdgeDistance reverse_distance; EdgeDistance reverse_distance;
EdgeDistance forward_distance_offset; // TODO: try to remove -> requires path unpacking changes EdgeDistance forward_distance_offset; // TODO: try to remove -> requires path unpacking changes
EdgeDistance reverse_distance_offset; // TODO: try to remove -> requires path unpacking changes EdgeDistance reverse_distance_offset; // TODO: try to remove -> requires path unpacking changes
EdgeWeight forward_duration; EdgeDuration forward_duration;
EdgeWeight reverse_duration; EdgeDuration reverse_duration;
EdgeWeight forward_duration_offset; // TODO: try to remove -> requires path unpacking changes EdgeDuration forward_duration_offset; // TODO: try to remove -> requires path unpacking changes
EdgeWeight reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes EdgeDuration reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes
EdgeDuration forward_duration_penalty;
EdgeDuration reverse_duration_penalty;
ComponentID component; ComponentID component;
util::Coordinate location; // this is the coordinate of x util::Coordinate location; // this is the coordinate of x
@@ -219,7 +227,7 @@ struct PhantomNode
unsigned short bearing : 12; unsigned short bearing : 12;
}; };
static_assert(sizeof(PhantomNode) == 80, "PhantomNode has more padding then expected"); static_assert(sizeof(PhantomNode) == 88, "PhantomNode has more padding then expected");
using PhantomNodePair = std::pair<PhantomNode, PhantomNode>; using PhantomNodePair = std::pair<PhantomNode, PhantomNode>;
@@ -234,7 +242,7 @@ struct PhantomNodes
PhantomNode source_phantom; PhantomNode source_phantom;
PhantomNode target_phantom; PhantomNode target_phantom;
}; };
} } // namespace engine
} } // namespace osrm
#endif // PHANTOM_NODES_H #endif // PHANTOM_NODES_H
+14 -4
View File
@@ -298,7 +298,9 @@ class BasePlugin
parameters.bearings[i]->bearing, parameters.bearings[i]->bearing,
parameters.bearings[i]->range, parameters.bearings[i]->range,
approach, approach,
use_all_edges); use_all_edges,
parameters.min_stoppage_penalty,
parameters.max_stoppage_penalty);
} }
else else
{ {
@@ -308,7 +310,9 @@ class BasePlugin
parameters.bearings[i]->bearing, parameters.bearings[i]->bearing,
parameters.bearings[i]->range, parameters.bearings[i]->range,
approach, approach,
use_all_edges); use_all_edges,
parameters.min_stoppage_penalty,
parameters.max_stoppage_penalty);
} }
} }
else else
@@ -320,13 +324,19 @@ class BasePlugin
parameters.coordinates[i], parameters.coordinates[i],
*parameters.radiuses[i], *parameters.radiuses[i],
approach, approach,
use_all_edges); use_all_edges,
parameters.min_stoppage_penalty,
parameters.max_stoppage_penalty);
} }
else else
{ {
phantom_node_pairs[i] = phantom_node_pairs[i] =
facade.NearestPhantomNodeWithAlternativeFromBigComponent( facade.NearestPhantomNodeWithAlternativeFromBigComponent(
parameters.coordinates[i], approach, use_all_edges); parameters.coordinates[i],
approach,
use_all_edges,
parameters.min_stoppage_penalty,
parameters.max_stoppage_penalty);
} }
} }
@@ -86,7 +86,7 @@ void insertSourceInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no
heap.Insert(phantom_node.forward_segment_id.id, heap.Insert(phantom_node.forward_segment_id.id,
-phantom_node.GetForwardWeightPlusOffset(), -phantom_node.GetForwardWeightPlusOffset(),
{phantom_node.forward_segment_id.id, {phantom_node.forward_segment_id.id,
-phantom_node.GetForwardDuration(), -phantom_node.GetForwardDuration() + phantom_node.forward_duration_penalty,
-phantom_node.GetForwardDistance()}); -phantom_node.GetForwardDistance()});
} }
if (phantom_node.IsValidReverseSource()) if (phantom_node.IsValidReverseSource())
@@ -94,7 +94,7 @@ void insertSourceInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no
heap.Insert(phantom_node.reverse_segment_id.id, heap.Insert(phantom_node.reverse_segment_id.id,
-phantom_node.GetReverseWeightPlusOffset(), -phantom_node.GetReverseWeightPlusOffset(),
{phantom_node.reverse_segment_id.id, {phantom_node.reverse_segment_id.id,
-phantom_node.GetReverseDuration(), -phantom_node.GetReverseDuration() + phantom_node.reverse_duration_penalty,
-phantom_node.GetReverseDistance()}); -phantom_node.GetReverseDistance()});
} }
} }
@@ -107,7 +107,7 @@ void insertTargetInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no
heap.Insert(phantom_node.forward_segment_id.id, heap.Insert(phantom_node.forward_segment_id.id,
phantom_node.GetForwardWeightPlusOffset(), phantom_node.GetForwardWeightPlusOffset(),
{phantom_node.forward_segment_id.id, {phantom_node.forward_segment_id.id,
phantom_node.GetForwardDuration(), phantom_node.GetForwardDuration() + phantom_node.forward_duration_penalty,
phantom_node.GetForwardDistance()}); phantom_node.GetForwardDistance()});
} }
if (phantom_node.IsValidReverseTarget()) if (phantom_node.IsValidReverseTarget())
@@ -115,7 +115,7 @@ void insertTargetInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no
heap.Insert(phantom_node.reverse_segment_id.id, heap.Insert(phantom_node.reverse_segment_id.id,
phantom_node.GetReverseWeightPlusOffset(), phantom_node.GetReverseWeightPlusOffset(),
{phantom_node.reverse_segment_id.id, {phantom_node.reverse_segment_id.id,
phantom_node.GetReverseDuration(), phantom_node.GetReverseDuration() + phantom_node.reverse_duration_penalty,
phantom_node.GetReverseDistance()}); phantom_node.GetReverseDistance()});
} }
} }
-2
View File
@@ -55,7 +55,6 @@ struct ExtractorConfig final : storage::IOConfig
".osrm.geometry", ".osrm.geometry",
".osrm.nbg_nodes", ".osrm.nbg_nodes",
".osrm.ebg_nodes", ".osrm.ebg_nodes",
".osrm.timestamp",
".osrm.edges", ".osrm.edges",
".osrm.ebg", ".osrm.ebg",
".osrm.ramIndex", ".osrm.ramIndex",
@@ -83,7 +82,6 @@ struct ExtractorConfig final : storage::IOConfig
boost::filesystem::path input_path; boost::filesystem::path input_path;
boost::filesystem::path profile_path; boost::filesystem::path profile_path;
std::vector<boost::filesystem::path> location_dependent_data_paths; std::vector<boost::filesystem::path> location_dependent_data_paths;
std::string data_version;
unsigned requested_num_threads; unsigned requested_num_threads;
unsigned small_component_size; unsigned small_component_size;
-20
View File
@@ -308,26 +308,6 @@ inline void writeTurnLaneData(const boost::filesystem::path &path,
storage::serialization::write(writer, "/common/turn_lanes/data", turn_lane_data); 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 &timestamp)
{
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 &timestamp)
{
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
storage::tar::FileWriter writer{path, fingerprint};
storage::serialization::write(writer, "/common/timestamp", timestamp);
}
// reads .osrm.maneuver_overrides // reads .osrm.maneuver_overrides
template <typename StorageManeuverOverrideT, typename NodeSequencesT> template <typename StorageManeuverOverrideT, typename NodeSequencesT>
inline void readManeuverOverrides(const boost::filesystem::path &path, inline void readManeuverOverrides(const boost::filesystem::path &path,
+81
View File
@@ -0,0 +1,81 @@
#include "util/typedefs.h"
namespace osrm
{
namespace extractor
{
namespace
{
constexpr int 5_MINUTE_BUCKETS_PER_WEEK = 2016;
constexpr int 1_HOUR_BUCKETS_PER_WEEK = 168;
} // namespace
/**
* Represents a simple piecewise linear function
* (https://en.wikipedia.org/wiki/Piecewise_linear_function)
* in the form of a regularly spaced set of buckets.
* Assumes that the spacing between buckets is equal.
*/
template <typename DataType, int BUCKETCOUNT> struct PiecewiseLinearFunction
{
std::array<DataType, BUCKETCOUNT> sample;
inline DataType getAt(float position)
{
// Range check
assert(position >= 0);
assert(position < BUCKETCOUNT - 1);
}
PiecewiseLinearFunction<DataType, BUCKETCOUNT>
merge(PiecewiseLinearFunction<DataType, BUCKETCOUNT> &other, float offset)
{
PiecewiseLinearFunction result;
for (int i = 0; i < BUCKETCOUNT; i++)
{
for (int j = offset; j < BUCKETCOUNT + offset; j++)
{
result.sample[i] = sample[i] + other.sample[j % BUCKETCOUNT];
}
}
return std::move(result);
}
}
/**
* Represents variances in the default `.duration` of an edge
* over the space of a week.
*/
struct WeeklySpeedProfile
{
using Multiplier = std::uint8_t;
private:
PiecewiseLinearFunction<Multiplier, 1_HOUR_BUCKETS_PER_WEEK> fn;
public:
SpeedProfile() : min(0), max(0) { multipliers.fill(0); }
SpeedProfile(const std::array<Multiplier, BUCKETS> &other)
{
fn.samples = other;
min = std::min(samples);
max = std::max(samples);
}
inline EdgeDuration adjust(const EdgeDuration &original, const int bucket) const
{
// Treat Multiplier as an 8-bit fixed-point value.
EdgeDuration new_value = (original * multipliers[bucket]);
}
inline EdgeDuration min(const EdgeDuration original) const {}
inline EdgeDuration max(const EdgeDuration original) const {}
duration = m * e1 + m2 * e2
};
} // namespace extractor
} // namespace osrm
+74 -95
View File
@@ -692,6 +692,80 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
} }
} }
if (obj->Has(Nan::New("snapping").ToLocalChecked()))
{
v8::Local<v8::Value> snapping = obj->Get(Nan::New("snapping").ToLocalChecked());
if (snapping.IsEmpty())
return false;
if (!snapping->IsString())
{
Nan::ThrowError("Snapping must be a string: [default, any]");
return false;
}
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 false;
}
}
if (obj->Has(Nan::New("stoppage_penalty").ToLocalChecked()))
{
v8::Local<v8::Value> stoppage_penalty =
obj->Get(Nan::New("stoppage_penalty").ToLocalChecked());
if (stoppage_penalty.IsEmpty())
return false;
if (!stoppage_penalty->IsArray())
{
Nan::ThrowError("Stoppage penalty must be an array of 2 numbers [min,max]");
return false;
}
auto stoppage_penalty_array = v8::Local<v8::Array>::Cast(stoppage_penalty);
if (stoppage_penalty_array->Length() != 2)
{
Nan::ThrowError("Stoppage penalty must be an array of 2 numbers [min,max]");
return false;
}
if (!stoppage_penalty_array->Get(0)->IsNumber() ||
!stoppage_penalty_array->Get(1)->IsNumber())
{
Nan::ThrowError("Stoppage penalty must be an array of 2 numbers [min,max]");
return false;
}
const auto min = static_cast<short>(stoppage_penalty_array->Get(0)->NumberValue());
const auto max = static_cast<short>(stoppage_penalty_array->Get(1)->NumberValue());
if (min < 0 || max < 0)
{
Nan::ThrowError("Stoppage penalty min/max can't be less than zero");
return false;
}
if (max < min)
{
Nan::ThrowError("Stoppage penalty max must be larger than min");
return false;
}
params->max_stoppage_penalty = max;
params->min_stoppage_penalty = min;
}
return true; return true;
} }
@@ -944,101 +1018,6 @@ 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); bool parsedSuccessfully = parseCommonParameters(obj, params);
if (!parsedSuccessfully) if (!parsedSuccessfully)
{ {
+13 -1
View File
@@ -135,6 +135,16 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
}, },
qi::_1)]; qi::_1)];
stoppage_rule = qi::lit("stoppage_penalty=") >
(qi::double_ > ',' > qi::double_)[ph::bind(
[](engine::api::BaseParameters &params, double min, double max) {
params.min_stoppage_penalty = min;
params.max_stoppage_penalty = max;
},
qi::_r1,
qi::_1,
qi::_2)];
query_rule = query_rule =
((location_rule % ';') | polyline_rule | ((location_rule % ';') | polyline_rule |
polyline6_rule)[ph::bind(&engine::api::BaseParameters::coordinates, qi::_r1) = qi::_1]; polyline6_rule)[ph::bind(&engine::api::BaseParameters::coordinates, qi::_r1) = qi::_1];
@@ -179,7 +189,8 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
| generate_hints_rule(qi::_r1) // | generate_hints_rule(qi::_r1) //
| approach_rule(qi::_r1) // | approach_rule(qi::_r1) //
| exclude_rule(qi::_r1) // | exclude_rule(qi::_r1) //
| snapping_rule(qi::_r1); | snapping_rule(qi::_r1) //
| stoppage_rule(qi::_r1); //
} }
protected: protected:
@@ -196,6 +207,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
qi::rule<Iterator, Signature> generate_hints_rule; qi::rule<Iterator, Signature> generate_hints_rule;
qi::rule<Iterator, Signature> approach_rule; qi::rule<Iterator, Signature> approach_rule;
qi::rule<Iterator, Signature> exclude_rule; qi::rule<Iterator, Signature> exclude_rule;
qi::rule<Iterator, Signature> stoppage_rule;
qi::rule<Iterator, osrm::engine::Bearing()> bearing_rule; qi::rule<Iterator, osrm::engine::Bearing()> bearing_rule;
qi::rule<Iterator, osrm::util::Coordinate()> location_rule; qi::rule<Iterator, osrm::util::Coordinate()> location_rule;
@@ -42,12 +42,17 @@ struct MatchParametersGrammar final : public RouteParametersGrammar<Iterator, Si
(qi::uint_ % (qi::uint_ %
';')[ph::bind(&engine::api::MatchParameters::timestamps, qi::_r1) = qi::_1]; ';')[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)( gaps_type.add("split", engine::api::MatchParameters::GapsType::Split)(
"ignore", engine::api::MatchParameters::GapsType::Ignore); "ignore", engine::api::MatchParameters::GapsType::Ignore);
root_rule = root_rule =
BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") > BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
-('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1) | -('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1) |
waypoints_rule(qi::_r1) |
(qi::lit("gaps=") > (qi::lit("gaps=") >
gaps_type[ph::bind(&engine::api::MatchParameters::gaps, qi::_r1) = qi::_1]) | gaps_type[ph::bind(&engine::api::MatchParameters::gaps, qi::_r1) = qi::_1]) |
(qi::lit("tidy=") > (qi::lit("tidy=") >
@@ -58,6 +63,7 @@ struct MatchParametersGrammar final : public RouteParametersGrammar<Iterator, Si
private: private:
qi::rule<Iterator, Signature> root_rule; qi::rule<Iterator, Signature> root_rule;
qi::rule<Iterator, Signature> timestamps_rule; qi::rule<Iterator, Signature> timestamps_rule;
qi::rule<Iterator, Signature> waypoints_rule;
qi::rule<Iterator, std::size_t()> size_t_; qi::rule<Iterator, std::size_t()> size_t_;
qi::symbols<char, engine::api::MatchParameters::GapsType> gaps_type; qi::symbols<char, engine::api::MatchParameters::GapsType> gaps_type;
@@ -48,14 +48,6 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
RouteParametersGrammar(qi::rule<Iterator, Signature> &root_rule_) : BaseGrammar(root_rule_) 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; using AnnotationsType = engine::api::RouteParameters::AnnotationsType;
const auto add_annotation = [](engine::api::RouteParameters &route_parameters, const auto add_annotation = [](engine::api::RouteParameters &route_parameters,
@@ -78,12 +70,8 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
"distance", AnnotationsType::Distance)("weight", AnnotationsType::Weight)( "distance", AnnotationsType::Distance)("weight", AnnotationsType::Weight)(
"datasources", AnnotationsType::Datasources)("speed", AnnotationsType::Speed); "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 = base_rule =
BaseGrammar::base_rule(qi::_r1) | waypoints_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1) |
(qi::lit("steps=") > (qi::lit("steps=") >
qi::bool_[ph::bind(&engine::api::RouteParameters::steps, qi::_r1) = qi::_1]) | qi::bool_[ph::bind(&engine::api::RouteParameters::steps, qi::_r1) = qi::_1]) |
(qi::lit("geometries=") > (qi::lit("geometries=") >
@@ -106,8 +94,6 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
private: private:
qi::rule<Iterator, Signature> root_rule; qi::rule<Iterator, Signature> root_rule;
qi::rule<Iterator, Signature> route_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::GeometriesType> geometries_type;
qi::symbols<char, engine::api::RouteParameters::OverviewType> overview_type; qi::symbols<char, engine::api::RouteParameters::OverviewType> overview_type;
@@ -18,7 +18,7 @@ namespace
{ {
namespace ph = boost::phoenix; namespace ph = boost::phoenix;
namespace qi = boost::spirit::qi; namespace qi = boost::spirit::qi;
} } // namespace
template <typename Iterator = std::string::iterator, template <typename Iterator = std::string::iterator,
typename Signature = void(engine::api::TableParameters &)> typename Signature = void(engine::api::TableParameters &)>
@@ -106,8 +106,8 @@ struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature
fallback_coordinate_type; fallback_coordinate_type;
qi::real_parser<double, json_policy> double_; qi::real_parser<double, json_policy> double_;
}; };
} } // namespace api
} } // namespace server
} } // namespace osrm
#endif #endif
-1
View File
@@ -58,7 +58,6 @@ struct StorageConfig final : IOConfig
".osrm.turn_duration_penalties", ".osrm.turn_duration_penalties",
".osrm.datasource_names", ".osrm.datasource_names",
".osrm.names", ".osrm.names",
".osrm.timestamp",
".osrm.properties", ".osrm.properties",
".osrm.icd", ".osrm.icd",
".osrm.maneuver_overrides"}, ".osrm.maneuver_overrides"},
-5
View File
@@ -272,11 +272,6 @@ inline auto make_partition_view(const SharedDataIndex &index, const std::string
level_data_ptr, std::move(partition), std::move(cell_to_children)}; 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) inline auto make_cell_storage_view(const SharedDataIndex &index, const std::string &name)
{ {
auto source_boundary = make_vector_view<NodeID>(index, name + "/source_boundary"); auto source_boundary = make_vector_view<NodeID>(index, name + "/source_boundary");
+2 -2
View File
@@ -488,8 +488,8 @@ inline void Prettify(char *buffer, int length, int k)
inline void dtoa_milo(double value, char *buffer) inline void dtoa_milo(double value, char *buffer)
{ {
// Not handling NaN and inf // Not handling NaN and inf
assert(!isnan(value)); assert(!std::isnan(value));
assert(!isinf(value)); assert(!std::isinf(value));
if (value == 0) if (value == 0)
{ {
+6 -3
View File
@@ -48,7 +48,7 @@ struct osm_way_id
struct duplicated_node struct duplicated_node
{ {
}; };
} } // namespace tag
using OSMNodeID = osrm::Alias<std::uint64_t, tag::osm_node_id>; using OSMNodeID = osrm::Alias<std::uint64_t, tag::osm_node_id>;
static_assert(std::is_pod<OSMNodeID>(), "OSMNodeID is not a valid alias"); static_assert(std::is_pod<OSMNodeID>(), "OSMNodeID is not a valid alias");
using OSMWayID = osrm::Alias<std::uint64_t, tag::osm_way_id>; using OSMWayID = osrm::Alias<std::uint64_t, tag::osm_way_id>;
@@ -79,7 +79,6 @@ using EdgeDistance = float;
using SegmentWeight = std::uint32_t; using SegmentWeight = std::uint32_t;
using SegmentDuration = std::uint32_t; using SegmentDuration = std::uint32_t;
using TurnPenalty = std::int16_t; // turn penalty in 100ms units 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(); static const std::size_t INVALID_INDEX = std::numeric_limits<std::size_t>::max();
@@ -117,7 +116,11 @@ static const EdgeDuration MAXIMAL_EDGE_DURATION = std::numeric_limits<EdgeDurati
static const EdgeDistance MAXIMAL_EDGE_DISTANCE = std::numeric_limits<EdgeDistance>::max(); static const EdgeDistance MAXIMAL_EDGE_DISTANCE = std::numeric_limits<EdgeDistance>::max();
static const TurnPenalty INVALID_TURN_PENALTY = std::numeric_limits<TurnPenalty>::max(); static const TurnPenalty INVALID_TURN_PENALTY = std::numeric_limits<TurnPenalty>::max();
static const EdgeDistance INVALID_EDGE_DISTANCE = std::numeric_limits<EdgeDistance>::max(); static const EdgeDistance INVALID_EDGE_DISTANCE = std::numeric_limits<EdgeDistance>::max();
static const EdgeDistance INVALID_FALLBACK_SPEED = std::numeric_limits<double>::max(); static const EdgeDistance INVALID_FALLBACK_SPEED = std::numeric_limits<EdgeDistance>::max();
constexpr EdgeDuration INVALID_MINIMUM_STOPPAGE_PENALTY = std::numeric_limits<EdgeDuration>::max();
constexpr EdgeDuration INVALID_MAXIMUM_STOPPAGE_PENALTY = std::numeric_limits<EdgeDuration>::max();
constexpr double MINIMAL_ACCEL_DECEL_PENALIZABLE_SPEED = 10; // metres/second
constexpr double MAXIMAL_ACCEL_DECEL_PENALIZABLE_SPEED = 40; // metres/sec
// FIXME the bitfields we use require a reduced maximal duration, this should be kept consistent // FIXME the bitfields we use require a reduced maximal duration, this should be kept consistent
// within the code base. For now we have to ensure that we don't case 30 bit to -1 and break any // within the code base. For now we have to ensure that we don't case 30 bit to -1 and break any
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "osrm", "name": "osrm",
"version": "5.22.0-customsnapping.2", "version": "5.21.0-customsnapping.4",
"private": false, "private": false,
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.", "description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
"dependencies": { "dependencies": {
+11 -4
View File
@@ -98,7 +98,9 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
std::vector<api::TableAPI::TableCellRef> estimated_pairs; std::vector<api::TableAPI::TableCellRef> estimated_pairs;
// Scan table for null results - if any exist, replace with distance estimates // Scan table for null results - if any exist, replace with distance estimates
if (params.fallback_speed != INVALID_FALLBACK_SPEED || params.scale_factor != 1) if (params.fallback_speed != INVALID_FALLBACK_SPEED || params.scale_factor != 1 ||
(params.min_stoppage_penalty != INVALID_MINIMUM_STOPPAGE_PENALTY &&
params.max_stoppage_penalty != INVALID_MAXIMUM_STOPPAGE_PENALTY))
{ {
for (std::size_t row = 0; row < num_sources; row++) for (std::size_t row = 0; row < num_sources; row++)
{ {
@@ -106,6 +108,10 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
{ {
const auto &table_index = row * num_destinations + column; const auto &table_index = row * num_destinations + column;
BOOST_ASSERT(table_index < result_tables_pair.first.size()); BOOST_ASSERT(table_index < result_tables_pair.first.size());
// Zero out the diagonal
if (result_tables_pair.first[table_index] != MAXIMAL_EDGE_DURATION && row == column)
result_tables_pair.first[table_index] = 0;
// Estimate null results based on fallback_speed (if valid) and distance
if (params.fallback_speed != INVALID_FALLBACK_SPEED && params.fallback_speed > 0 && if (params.fallback_speed != INVALID_FALLBACK_SPEED && params.fallback_speed > 0 &&
result_tables_pair.first[table_index] == MAXIMAL_EDGE_DURATION) result_tables_pair.first[table_index] == MAXIMAL_EDGE_DURATION)
{ {
@@ -132,6 +138,7 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
estimated_pairs.emplace_back(row, column); estimated_pairs.emplace_back(row, column);
} }
// Apply a scale factor to non-null result if requested
if (params.scale_factor > 0 && params.scale_factor != 1 && if (params.scale_factor > 0 && params.scale_factor != 1 &&
result_tables_pair.first[table_index] != MAXIMAL_EDGE_DURATION && result_tables_pair.first[table_index] != MAXIMAL_EDGE_DURATION &&
result_tables_pair.first[table_index] != 0) result_tables_pair.first[table_index] != 0)
@@ -158,6 +165,6 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
return Status::Ok; return Status::Ok;
} }
} } // namespace plugins
} } // namespace engine
} } // namespace osrm
+1 -31
View File
@@ -73,16 +73,6 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
return Error("InvalidValue", "Invalid coordinate value.", json_result); 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)) if (!CheckAlgorithms(route_parameters, algorithms, json_result))
return Status::Error; return Status::Error;
@@ -142,27 +132,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
if (routes.routes[0].is_valid()) if (routes.routes[0].is_valid())
{ {
auto collapse_legs = !route_parameters.waypoints.empty(); route_api.MakeResponse(routes, json_result);
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 else
{ {
-9
View File
@@ -51,7 +51,6 @@
#include <osmium/handler/node_locations_for_ways.hpp> #include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/index/map/flex_mem.hpp> #include <osmium/index/map/flex_mem.hpp>
#include <osmium/io/any_input.hpp> #include <osmium/io/any_input.hpp>
#include <osmium/osm/timestamp.hpp>
#include <osmium/thread/pool.hpp> #include <osmium/thread/pool.hpp>
#include <osmium/visitor.hpp> #include <osmium/visitor.hpp>
@@ -426,14 +425,6 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
// write .timestamp data file // write .timestamp data file
std::string timestamp = header.get("osmosis_replication_timestamp"); 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()) if (timestamp.empty())
{ {
timestamp = "n/a"; timestamp = "n/a";
-12
View File
@@ -302,7 +302,6 @@ std::vector<std::pair<bool, boost::filesystem::path>> Storage::GetStaticFiles()
{REQUIRED, config.GetPath(".osrm.ebg_nodes")}, {REQUIRED, config.GetPath(".osrm.ebg_nodes")},
{REQUIRED, config.GetPath(".osrm.tls")}, {REQUIRED, config.GetPath(".osrm.tls")},
{REQUIRED, config.GetPath(".osrm.tld")}, {REQUIRED, config.GetPath(".osrm.tld")},
{REQUIRED, config.GetPath(".osrm.timestamp")},
{REQUIRED, config.GetPath(".osrm.maneuver_overrides")}, {REQUIRED, config.GetPath(".osrm.maneuver_overrides")},
{REQUIRED, config.GetPath(".osrm.edges")}, {REQUIRED, config.GetPath(".osrm.edges")},
{REQUIRED, config.GetPath(".osrm.names")}, {REQUIRED, config.GetPath(".osrm.names")},
@@ -402,17 +401,6 @@ void Storage::PopulateStaticData(const SharedDataIndex &index)
extractor::files::readNames(config.GetPath(".osrm.names"), name_table); 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 // Turn lane data
{ {
auto turn_lane_data = make_lane_data_view(index, "/common/turn_lanes"); auto turn_lane_data = make_lane_data_view(index, "/common/turn_lanes");
-4
View File
@@ -43,10 +43,6 @@ return_code parseArguments(int argc,
boost::program_options::value<boost::filesystem::path>(&extractor_config.profile_path) boost::program_options::value<boost::filesystem::path>(&extractor_config.profile_path)
->default_value("profiles/car.lua"), ->default_value("profiles/car.lua"),
"Path to LUA routing profile")( "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", "threads,t",
boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads) boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads)
->default_value(tbb::task_scheduler_init::default_num_threads()), ->default_value(tbb::task_scheduler_init::default_num_threads()),
-24
View File
@@ -319,30 +319,6 @@ test('match: throws on invalid waypoints values, waypoints must correspond with
'Waypoints must correspond with the index of an input coordinate'); '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) { test('match: error on split trace', function(assert) {
assert.plan(1); assert.plan(1);
var osrm = new OSRM(data_path); var osrm = new OSRM(data_path);
-85
View File
@@ -606,91 +606,6 @@ 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) { test('route: throws on invalid snapping values', function (assert) {
assert.plan(1); assert.plan(1);
var osrm = new OSRM(monaco_path); var osrm = new OSRM(monaco_path);
+43
View File
@@ -48,6 +48,21 @@ test('table: test annotations paramater combination', function(assert) {
}); });
}); });
test('table: snapping parameter passed through OK', function(assert) {
assert.plan(2);
var osrm = new OSRM(data_path);
var options = {
coordinates: [[7.448205209414596,43.754001097311544],[7.447122039202185,43.75306156811368]],
annotations: ['duration', 'distance'],
snapping: 'any'
};
console.log(options);
osrm.table(options, function(err, result) {
assert.ifError(err);
assert.equal(Math.round(result.distances[0][1] * 10), 1315); // Round it to nearest 0.1m to eliminate floating point comparison error
});
});
test('table: returns buffer', function(assert) { test('table: returns buffer', function(assert) {
assert.plan(3); assert.plan(3);
var osrm = new OSRM(data_path); var osrm = new OSRM(data_path);
@@ -303,5 +318,33 @@ tables.forEach(function(annotation) {
assert.throws(()=>osrm.table(options, (err, res) => {}), /scale_factor must be > 0/, "should throw on invalid scale_factor value"); assert.throws(()=>osrm.table(options, (err, res) => {}), /scale_factor must be > 0/, "should throw on invalid scale_factor value");
}); });
test('table: ' + annotation + ' table in Monaco with stoppage_penalty values', function(assert) {
assert.plan(6);
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
var options = {
coordinates: two_test_coordinates,
annotations: [annotation.slice(0,-1)],
stoppage_penalty: [],
};
assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty must be an array of 2 numbers/, "should throw on empty array");
options.stoppage_penalty = ['a',1];
assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty must be an array of 2 numbers/, "should throw on non-numeric value");
options.stoppage_penalty = [1,2,3];
assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty must be an array of 2 numbers/, "should throw on too many values");
options.stoppage_penalty = [1];
assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty must be an array of 2 numbers/, "should throw on not enough values");
options.stoppage_penalty = [2,1];
assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty max must be larger than min/, "should throw on max < min");
options.stoppage_penalty = [-1,2];
assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty min\/max can't be less than zero/, "should throw on negative value");
});
}); });
+30 -23
View File
@@ -282,40 +282,48 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
return {}; return {};
} }
std::pair<PhantomNode, PhantomNode> std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, const util::Coordinate /*input_coordinate*/,
const Approach /*approach*/, const Approach /*approach*/,
const bool /* use_all_edges */) const override const bool /* use_all_edges */,
const double /* min_stoppage_penalty */,
const double /* max_stoppage_penalty */) const override
{ {
return {}; return {};
} }
std::pair<PhantomNode, PhantomNode> std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, const util::Coordinate /*input_coordinate*/,
const double /*max_distance*/, const double /*max_distance*/,
const Approach /*approach*/, const Approach /*approach*/,
const bool /* use_all_edges */) const override const bool /* use_all_edges */,
const double /* min_stoppage_penalty */,
const double /* max_stoppage_penalty */) const override
{ {
return {}; return {};
} }
std::pair<PhantomNode, PhantomNode> std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, const util::Coordinate /*input_coordinate*/,
const double /*max_distance*/, const double /*max_distance*/,
const int /*bearing*/, const int /*bearing*/,
const int /*bearing_range*/, const int /*bearing_range*/,
const Approach /*approach*/, const Approach /*approach*/,
const bool /* use_all_edges */) const override const bool /* use_all_edges */,
const double /* min_stoppage_penalty */,
const double /* max_stoppage_penalty */) const override
{ {
return {}; return {};
} }
std::pair<PhantomNode, PhantomNode> std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, const util::Coordinate /*input_coordinate*/,
const int /*bearing*/, const int /*bearing*/,
const int /*bearing_range*/, const int /*bearing_range*/,
const Approach /*approach*/, const Approach /*approach*/,
const bool /* use_all_edges */) const override const bool /* use_all_edges */,
const double /* min_stoppage_penalty */,
const double /* max_stoppage_penalty */) const override
{ {
return {}; return {};
} }
@@ -345,7 +353,6 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
StringView GetDestinationsForID(const NameID /*id*/) const override { return StringView{}; } StringView GetDestinationsForID(const NameID /*id*/) const override { return StringView{}; }
StringView GetExitsForID(const NameID /*id*/) const override { return StringView{}; } StringView GetExitsForID(const NameID /*id*/) const override { return StringView{}; }
bool GetContinueStraightDefault() const override { return false; } bool GetContinueStraightDefault() const override { return false; }
std::string GetTimestamp() const override { return ""; }
double GetMapMatchingMaxSpeed() const override { return 0; } double GetMapMatchingMaxSpeed() const override { return 0; }
const char *GetWeightName() const override { return ""; } const char *GetWeightName() const override { return ""; }
unsigned GetWeightPrecision() const override { return 0; } unsigned GetWeightPrecision() const override { return 0; }
+31 -19
View File
@@ -10,6 +10,7 @@
#include "extractor/turn_lane_types.hpp" #include "extractor/turn_lane_types.hpp"
#include "guidance/turn_bearing.hpp" #include "guidance/turn_bearing.hpp"
#include "guidance/turn_instruction.hpp" #include "guidance/turn_instruction.hpp"
#include "guidance/turn_instruction.hpp"
#include "engine/algorithm.hpp" #include "engine/algorithm.hpp"
#include "engine/datafacade/algorithm_datafacade.hpp" #include "engine/datafacade/algorithm_datafacade.hpp"
@@ -53,7 +54,6 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
{ {
return 0; return 0;
} }
std::string GetTimestamp() const override { return ""; }
NodeForwardRange GetUncompressedForwardGeometry(const EdgeID /* id */) const override NodeForwardRange GetUncompressedForwardGeometry(const EdgeID /* id */) const override
{ {
static NodeID data[] = {0, 1, 2, 3}; static NodeID data[] = {0, 1, 2, 3};
@@ -167,39 +167,51 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
} }
std::pair<engine::PhantomNode, engine::PhantomNode> std::pair<engine::PhantomNode, engine::PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, NearestPhantomNodeWithAlternativeFromBigComponent(
const engine::Approach /*approach*/, const util::Coordinate /*input_coordinate*/,
const bool /* use_all_edges */) const override const engine::Approach /*approach*/,
const bool /* use_all_edges */,
const double /* min_stoppage_penalty */,
const double /* max_stoppage_penalty */) const override
{ {
return {}; return {};
} }
std::pair<engine::PhantomNode, engine::PhantomNode> std::pair<engine::PhantomNode, engine::PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, NearestPhantomNodeWithAlternativeFromBigComponent(
const double /*max_distance*/, const util::Coordinate /*input_coordinate*/,
const engine::Approach /*approach*/, const double /*max_distance*/,
const bool /* use_all_edges */) const override const engine::Approach /*approach*/,
const bool /* use_all_edges */,
const double /* min_stoppage_penalty */,
const double /* max_stoppage_penalty */) const override
{ {
return {}; return {};
} }
std::pair<engine::PhantomNode, engine::PhantomNode> std::pair<engine::PhantomNode, engine::PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, NearestPhantomNodeWithAlternativeFromBigComponent(
const double /*max_distance*/, const util::Coordinate /*input_coordinate*/,
const int /*bearing*/, const double /*max_distance*/,
const int /*bearing_range*/, const int /*bearing*/,
const engine::Approach /*approach*/, const int /*bearing_range*/,
const bool /* use_all_edges */) const override const engine::Approach /*approach*/,
const bool /* use_all_edges */,
const double /* min_stoppage_penalty */,
const double /* max_stoppage_penalty */) const override
{ {
return {}; return {};
} }
std::pair<engine::PhantomNode, engine::PhantomNode> std::pair<engine::PhantomNode, engine::PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, NearestPhantomNodeWithAlternativeFromBigComponent(
const int /*bearing*/, const util::Coordinate /*input_coordinate*/,
const int /*bearing_range*/, const int /*bearing*/,
const engine::Approach /*approach*/, const int /*bearing_range*/,
const bool /* use_all_edges */) const override const engine::Approach /*approach*/,
const bool /* use_all_edges */,
const double /* min_stoppage_penalty */,
const double /* max_stoppage_penalty */) const override
{ {
return {}; return {};
} }