Compare commits

..

2 Commits

Author SHA1 Message Date
Patrick Niklaus fdbcefe358 Final OSRM release 2018-05-10 12:37:26 +00:00
Patrick Niklaus 853691aee2 Bump version 2018-05-08 15:56:18 +00:00
147 changed files with 11731 additions and 10864 deletions
-4
View File
@@ -68,10 +68,6 @@ Thumbs.db
/*.local.bat /*.local.bat
/CMakeSettings.json /CMakeSettings.json
# Jetbrains related files #
###########################
.idea/
# stxxl related files # # stxxl related files #
####################### #######################
.stxxl .stxxl
+65 -59
View File
@@ -13,12 +13,12 @@ notifications:
branches: branches:
only: only:
- master - master
- 5.21 - "5.18"
# enable building tags # enable building tags
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/ - /^v\d+\.\d+(\.\d+)?(-\S*)?$/
cache: cache:
npm: true yarn: true
ccache: true ccache: true
apt: true apt: true
directories: directories:
@@ -35,7 +35,7 @@ env:
- CMAKE_VERSION=3.7.2 - CMAKE_VERSION=3.7.2
- MASON="$(pwd)/scripts/mason.sh" - MASON="$(pwd)/scripts/mason.sh"
- ENABLE_NODE_BINDINGS=On - ENABLE_NODE_BINDINGS=On
- NODE="10" - NODE="4"
matrix: matrix:
fast_finish: true fast_finish: true
@@ -46,7 +46,7 @@ matrix:
# Debug Builds # Debug Builds
- os: linux - os: linux
compiler: "format-taginfo-docs" compiler: "format-taginfo-docs"
env: NODE=10 env: NODE=6
sudo: false sudo: false
before_install: before_install:
install: install:
@@ -54,7 +54,8 @@ matrix:
- nvm install $NODE - nvm install $NODE
- nvm use $NODE - nvm use $NODE
- npm --version - npm --version
- npm ci --ignore-scripts - npm install --ignore-scripts
- npm link --ignore-scripts
script: script:
- ./scripts/check_taginfo.py taginfo.json profiles/car.lua - ./scripts/check_taginfo.py taginfo.json profiles/car.lua
- ${MASON} install clang-format 3.8.1 - ${MASON} install clang-format 3.8.1
@@ -156,17 +157,17 @@ matrix:
- os: osx - os: osx
osx_image: xcode9.2 osx_image: xcode9.2
compiler: "mason-osx-release-node-10" compiler: "mason-osx-release-node-8"
# we use the xcode provides clang and don't install our own # 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="10" env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="8"
after_success: after_success:
- ./scripts/travis/publish.sh - ./scripts/travis/publish.sh
- os: osx - os: osx
osx_image: xcode9.2 osx_image: xcode9.2
compiler: "mason-osx-release-node-8" compiler: "mason-osx-release-node-4"
# we use the xcode provides clang and don't install our own # we use the xcode provides clang and don't install our own
env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="8" env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="4"
after_success: after_success:
- ./scripts/travis/publish.sh - ./scripts/travis/publish.sh
@@ -180,6 +181,54 @@ matrix:
env: CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release' BUILD_SHARED_LIBS=ON env: CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release' BUILD_SHARED_LIBS=ON
# Node build jobs. These skip running the tests. # Node build jobs. These skip running the tests.
- os: linux
sudo: false
compiler: "node-4-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="4"
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-4-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="4"
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 - os: linux
sudo: false sudo: false
compiler: "node-8-mason-linux-release" compiler: "node-8-mason-linux-release"
@@ -228,54 +277,6 @@ matrix:
after_success: after_success:
- ./scripts/travis/publish.sh - ./scripts/travis/publish.sh
- os: linux
sudo: false
compiler: "node-10-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="10"
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-10-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="10"
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
before_install: before_install:
- source $NVM_DIR/nvm.sh - source $NVM_DIR/nvm.sh
- nvm install $NODE - nvm install $NODE
@@ -294,10 +295,15 @@ before_install:
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
sudo mdutil -i off / sudo mdutil -i off /
fi fi
- |
if [[ ! -f $(which yarn) ]]; then
npm install -g yarn
fi
- export PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)") - export PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
- export PUBLISH=$([[ "${TRAVIS_TAG:-}" == "v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") - export PUBLISH=$([[ "${TRAVIS_TAG:-}" == "v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off")
- echo "Using ${JOBS} jobs" - echo "Using ${JOBS} jobs"
- npm ci --ignore-scripts - yarn install --ignore-scripts
- yarn check --ignore-scripts --integrity
# Bootstrap cmake to be able to run mason # Bootstrap cmake to be able to run mason
- CMAKE_URL="https://mason-binaries.s3.amazonaws.com/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}.tar.gz" - CMAKE_URL="https://mason-binaries.s3.amazonaws.com/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}.tar.gz"
- CMAKE_DIR="mason_packages/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}" - CMAKE_DIR="mason_packages/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}"
@@ -376,4 +382,4 @@ script:
fi fi
- | - |
- popd - popd
- npm test - yarn test
-51
View File
@@ -1,54 +1,3 @@
# 5.21.0
- Changes from 5.20.0
- Features:
- ADDED: all waypoints in responses now contain a distance property between the original coordinate and the snapped location. [#5255](https://github.com/Project-OSRM/osrm-backend/pull/5255)
- ADDED: if `fallback_speed` is used, a new structure `fallback_speed_cells` will describe which cells contain estimated values [#5259](https://github.com/Project-OSRM/osrm-backend/pull/5259)
- REMOVED: we no longer publish Node 4 or 6 binary modules (they are still buildable from source) [#5314](https://github.com/Project-OSRM/osrm-backend/pull/5314)
- Table:
- ADDED: new parameter `scale_factor` which will scale the cell `duration` values by this factor. [#5298](https://github.com/Project-OSRM/osrm-backend/pull/5298)
- FIXED: only trigger `scale_factor` code to scan matrix when necessary. [#5303](https://github.com/Project-OSRM/osrm-backend/pull/5303)
- FIXED: fix bug in reverse offset calculation that sometimes lead to negative (and other incorrect) values in distance table results [#5315](https://github.com/Project-OSRM/osrm-backend/pull/5315)
- Docker:
- FIXED: use consistent boost version between build and runtime [#5311](https://github.com/Project-OSRM/osrm-backend/pull/5311)
- FIXED: don't override default permissions on /opt [#5311](https://github.com/Project-OSRM/osrm-backend/pull/5311)
- Matching:
- CHANGED: matching will now consider edges marked with is_startpoint=false, allowing matching over ferries and other previously non-matchable edge types. [#5297](https://github.com/Project-OSRM/osrm-backend/pull/5297)
- Profile:
- ADDED: Parse `source:maxspeed` and `maxspeed:type` tags to apply maxspeeds and add belgian flanders rural speed limit. [#5217](https://github.com/Project-OSRM/osrm-backend/pull/5217)
- CHANGED: Refactor maxspeed parsing to use common library. [#5144](https://github.com/Project-OSRM/osrm-backend/pull/5144)
# 5.20.0
- Changes from 5.19.0:
- Table:
- CHANGED: switch to pre-calculated distances for table responses for large speedup and 10% memory increase. [#5251](https://github.com/Project-OSRM/osrm-backend/pull/5251)
- ADDED: new parameter `fallback_speed` which will fill `null` cells with estimated value [#5257](https://github.com/Project-OSRM/osrm-backend/pull/5257)
- CHANGED: Remove API check for matrix sources/destination length to be less than or equal to coordinates length. [#5298](https://github.com/Project-OSRM/osrm-backend/pull/5289)
- FIXED: Fix crashing bug when using fallback_speed parameter with more sources than destinations. [#5291](https://github.com/Project-OSRM/osrm-backend/pull/5291)
- Features:
- ADDED: direct mmapping of datafiles is now supported via the `--mmap` switch. [#5242](https://github.com/Project-OSRM/osrm-backend/pull/5242)
- REMOVED: the previous `--memory_file` switch is now deprecated and will fallback to `--mmap` [#5242](https://github.com/Project-OSRM/osrm-backend/pull/5242)
- ADDED: Now publishing Node 10.x LTS binary modules [#5246](https://github.com/Project-OSRM/osrm-backend/pull/5246)
- Windows:
- FIXED: Windows builds again. [#5249](https://github.com/Project-OSRM/osrm-backend/pull/5249)
- Docker:
- CHANGED: switch from Alpine Linux to Debian Buster base images [#5281](https://github.com/Project-OSRM/osrm-backend/pull/5281)
# 5.19.0
- Changes from 5.18.0:
- Optimizations:
- CHANGED: Use Grisu2 for serializing floating point numbers. [#5188](https://github.com/Project-OSRM/osrm-backend/pull/5188)
- ADDED: Node bindings can return pre-rendered JSON buffer. [#5189](https://github.com/Project-OSRM/osrm-backend/pull/5189)
- Profiles:
- CHANGED: Bicycle profile now blacklists barriers instead of whitelisting them [#5076
](https://github.com/Project-OSRM/osrm-backend/pull/5076/)
- CHANGED: Foot profile now blacklists barriers instead of whitelisting them [#5077
](https://github.com/Project-OSRM/osrm-backend/pull/5077/)
- CHANGED: Support maxlength and maxweight in car profile [#5101](https://github.com/Project-OSRM/osrm-backend/pull/5101]
- Bugfixes:
- FIXED: collapsing of ExitRoundabout instructions [#5114](https://github.com/Project-OSRM/osrm-backend/issues/5114)
- Misc:
- CHANGED: Support up to 512 named shared memory regions [#5185](https://github.com/Project-OSRM/osrm-backend/pull/5185)
# 5.18.0 # 5.18.0
- Changes from 5.17.0: - Changes from 5.17.0:
- Features: - Features:
+1 -1
View File
@@ -50,7 +50,7 @@ If you want to use the CH pipeline instead replace `osrm-partition` and `osrm-cu
### Using Docker ### Using Docker
We base our Docker images ([backend](https://hub.docker.com/r/osrm/osrm-backend/), [frontend](https://hub.docker.com/r/osrm/osrm-frontend/)) on Debian and make sure they are as lightweight as possible. We base our Docker images ([backend](https://hub.docker.com/r/osrm/osrm-backend/), [frontend](https://hub.docker.com/r/osrm/osrm-frontend/)) on Alpine Linux and make sure they are as lightweight as possible.
Download OpenStreetMap extracts for example from [Geofabrik](http://download.geofabrik.de/) Download OpenStreetMap extracts for example from [Geofabrik](http://download.geofabrik.de/)
+13 -12
View File
@@ -1,13 +1,15 @@
FROM debian:buster-slim as builder FROM alpine:3.6 as buildstage
ARG DOCKER_TAG ARG DOCKER_TAG
RUN mkdir -p /src && mkdir -p /opt RUN mkdir -p /src && mkdir -p /opt
COPY . /src COPY . /src
WORKDIR /src WORKDIR /src
RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
apt-get update && \ echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apt-get -y --no-install-recommends install cmake make git gcc g++ libbz2-dev libstxxl-dev libstxxl1v5 libxml2-dev \ apk update && \
libzip-dev libboost1.67-all-dev lua5.2 liblua5.2-dev libtbb-dev -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 && \ apk upgrade && \
apk add git cmake wget make libc-dev gcc g++ bzip2-dev boost-dev zlib-dev expat-dev lua5.2-dev libtbb@testing libtbb-dev@testing && \
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ 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 && \
@@ -24,21 +26,20 @@ RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
make -j${NPROC} install && \ make -j${NPROC} install && \
cd ../profiles && \ cd ../profiles && \
cp -r * /opt && \ cp -r * /opt && \
\
strip /usr/local/bin/* && \ strip /usr/local/bin/* && \
rm -rf /src /usr/local/lib/libosrm* rm -rf /src /usr/local/lib/libosrm*
# 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:buster-slim as runstage FROM alpine:3.6 as runstage
RUN mkdir -p /src && mkdir -p /opt RUN mkdir -p /src && mkdir -p /opt
RUN apt-get update && \ RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apt-get install -y --no-install-recommends libboost-program-options1.67.0 libboost-regex1.67.0 \ apk update && \
libboost-date-time1.67.0 libboost-chrono1.67.0 libboost-filesystem1.67.0 \ apk add boost-filesystem boost-program_options boost-regex boost-iostreams boost-thread libgomp lua5.2 expat libtbb@testing
libboost-iostreams1.67.0 libboost-thread1.67.0 expat liblua5.2-0 libtbb2 &&\ COPY --from=buildstage /usr/local /usr/local
rm -rf /var/lib/apt/lists/* COPY --from=buildstage /opt /opt
COPY --from=builder /usr/local /usr/local
COPY --from=builder /opt /opt
WORKDIR /opt WORKDIR /opt
EXPOSE 5000 EXPOSE 5000
+3 -11
View File
@@ -119,6 +119,7 @@ In addition to the [general options](#general-options) the following options are
- `code` if the request was successful `Ok` otherwise see the service dependent and general status codes. - `code` if the request was successful `Ok` otherwise see the service dependent and general status codes.
- `waypoints` array of `Waypoint` objects sorted by distance to the input coordinate. Each object has at least the following additional properties: - `waypoints` array of `Waypoint` objects sorted by distance to the input coordinate. Each object has at least the following additional properties:
- `distance`: Distance in meters to the supplied input coordinate.
- `nodes`: Array of OpenStreetMap node ids. - `nodes`: Array of OpenStreetMap node ids.
#### Example Requests #### Example Requests
@@ -235,10 +236,8 @@ In addition to the [general options](#general-options) the following options are
|------------|--------------------------------------------------|---------------------------------------------| |------------|--------------------------------------------------|---------------------------------------------|
|sources |`{index};{index}[;{index} ...]` or `all` (default)|Use location with given index as source. | |sources |`{index};{index}[;{index} ...]` or `all` (default)|Use location with given index as source. |
|destinations|`{index};{index}[;{index} ...]` or `all` (default)|Use location with given index as destination.| |destinations|`{index};{index}[;{index} ...]` or `all` (default)|Use location with given index as destination.|
|annotations |`duration` (default), `distance`, or `duration,distance`|Return the requested table or tables in response. | |annotations |`duration` (default), `distance`, or `duration,distance`|Return the requested table or tables in response. Note that computing the `distances` table is currently only implemented for CH. If `annotations=distance` or `annotations=duration,distance` is requested when running a MLD router, a `NotImplemented` error will be returned.
|fallback_speed|`double > 0`| If no route found between a source/destination pair, calculate the as-the-crow-flies distance, then use this speed to estimate duration.| |
|fallback_coordinate|`input` (default), or `snapped`| When using a `fallback_speed`, use the user-supplied coordinate (`input`), or the snapped location (`snapped`) for calculating distances.|
|scale_factor|`double > 0`| Use in conjunction with `annotations=durations`. Scales the table `duration` values by this number.|
Unlike other array encoded options, the length of `sources` and `destinations` can be **smaller or equal** Unlike other array encoded options, the length of `sources` and `destinations` can be **smaller or equal**
to number of input locations; to number of input locations;
@@ -284,7 +283,6 @@ curl 'http://router.project-osrm.org/table/v1/driving/13.388860,52.517037;13.397
the i-th waypoint to the j-th waypoint. Values are given in meters. Can be `null` if no route between `i` and `j` can be found. Note that computing the `distances` table is currently only implemented for CH. If `annotations=distance` or `annotations=duration,distance` is requested when running a MLD router, a `NotImplemented` error will be returned. the i-th waypoint to the j-th waypoint. Values are given in meters. Can be `null` if no route between `i` and `j` can be found. Note that computing the `distances` table is currently only implemented for CH. If `annotations=distance` or `annotations=duration,distance` is requested when running a MLD router, a `NotImplemented` error will be returned.
- `sources` array of `Waypoint` objects describing all sources in order - `sources` array of `Waypoint` objects describing all sources in order
- `destinations` array of `Waypoint` objects describing all destinations in order - `destinations` array of `Waypoint` objects describing all destinations in order
- `fallback_speed_cells` (optional) array of arrays containing `i,j` pairs indicating which cells contain estimated values based on `fallback_speed`. Will be absent if `fallback_speed` is not used.
In case of error the following `code`s are supported in addition to the general ones: In case of error the following `code`s are supported in addition to the general ones:
@@ -385,10 +383,6 @@ All other properties might be undefined.
2361.73, 2361.73,
0 0
] ]
],
"fallback_speed_cells": [
[ 0, 1 ],
[ 1, 0 ]
] ]
} }
``` ```
@@ -557,7 +551,6 @@ Vector tiles contain two layers:
| `weight ` | `integer` | how long this segment takes to traverse, in units (may differ from `duration` when artificial biasing is applied in the Lua profiles). ACTUAL ROUTING USES THIS VALUE. | | `weight ` | `integer` | how long this segment takes to traverse, in units (may differ from `duration` when artificial biasing is applied in the Lua profiles). ACTUAL ROUTING USES THIS VALUE. |
| `name` | `string` | the name of the road this segment belongs to | | `name` | `string` | the name of the road this segment belongs to |
| `rate` | `float` | the value of `length/weight` - analagous to `speed`, but using the `weight` value rather than `duration`, rounded to the nearest integer | | `rate` | `float` | the value of `length/weight` - analagous to `speed`, but using the `weight` value rather than `duration`, rounded to the nearest integer |
| `is_startpoint` | `boolean` | whether this segment can be used as a start/endpoint for routes |
`turns` layer: `turns` layer:
@@ -912,7 +905,6 @@ Object used to describe waypoint on a route.
- `name` Name of the street the coordinate snapped to - `name` Name of the street the coordinate snapped to
- `location` Array that contains the `[longitude, latitude]` pair of the snapped coordinate - `location` Array that contains the `[longitude, latitude]` pair of the snapped coordinate
- `distance` The distance, in metres, from the input coordinate to the snapped coordinate
- `hint` Unique internal identifier of the segment (ephemeral, not constant over data updates) - `hint` Unique internal identifier of the segment (ephemeral, not constant over data updates)
This can be used on subsequent request to significantly speed up the query and to connect multiple services. This can be used on subsequent request to significantly speed up the query and to connect multiple services.
E.g. you can use the `hint` value obtained by the `nearest` query as `hint` values for `route` inputs. E.g. you can use the `hint` value obtained by the `nearest` query as `hint` values for `route` inputs.
+19 -46
View File
@@ -25,9 +25,7 @@ var osrm = new OSRM('network.osrm');
Make sure you prepared the dataset with the correct toolchain. Make sure you prepared the dataset with the correct toolchain.
- `options.shared_memory` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Connects to the persistent shared memory datastore. - `options.shared_memory` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Connects to the persistent shared memory datastore.
This requires you to run `osrm-datastore` prior to creating an `OSRM` object. This requires you to run `osrm-datastore` prior to creating an `OSRM` object.
- `options.memory_file` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** *DEPRECATED* - `options.memory_file` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Path to a file on disk to store the memory using mmap.
Old behaviour: Path to a file on disk to store the memory using mmap. Current behaviour: setting this value is the same as setting `mmap_memory: true`.
- `options.mmap_memory` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Map on-disk files to virtual memory addresses (mmap), rather than loading into RAM.
- `options.path` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** The path to the `.osrm` files. This is mutually exclusive with setting {options.shared_memory} to true. - `options.path` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** The path to the `.osrm` files. This is mutually exclusive with setting {options.shared_memory} to true.
- `options.max_locations_trip` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. locations supported in trip query (default: unlimited). - `options.max_locations_trip` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. locations supported in trip query (default: unlimited).
- `options.max_locations_viaroute` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. locations supported in viaroute query (default: unlimited). - `options.max_locations_viaroute` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. locations supported in viaroute query (default: unlimited).
@@ -58,7 +56,7 @@ Returns the fastest route between two or more coordinates while visiting the way
- `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`.
`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)**
**Examples** **Examples**
@@ -90,7 +88,7 @@ Note: `coordinates` in the general options only supports a single `{longitude},{
- `options.number` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of nearest segments that should be returned. - `options.number` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of nearest segments that should be returned.
Must be an integer greater than or equal to `1`. (optional, default `1`) Must be an integer greater than or equal to `1`. (optional, default `1`)
- `options.approaches` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`. - `options.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`.
- `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**
@@ -129,10 +127,7 @@ tables. Optionally returns distance table.
- `options.destinations` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of `index` elements (`0 <= integer < - `options.destinations` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of `index` elements (`0 <= integer <
#coordinates`) to use location with given index as destination. Default is to use all. #coordinates`) to use location with given index as destination. Default is to use all.
- `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.fallback_speed` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Replace `null` responses in result with as-the-crow-flies estimates based on `fallback_speed`. Value is in metres/second. - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
- `options.fallback_coordinate` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Either `input` (default) or `snapped`. If using a `fallback_speed`, use either the user-supplied coordinate (`input`), or the snapped coordinate (`snapped`) for calculating the as-the-crow-flies diestance between two points.
- `options.scale_factor` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Multiply the table duration values in the table by this number for more controlled input into a route optimization solver.
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
**Examples** **Examples**
@@ -157,7 +152,6 @@ Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer
Values are given in seconds. Values are given in seconds.
**`sources`**: array of [`Ẁaypoint`](#waypoint) objects describing all sources in order. **`sources`**: array of [`Ẁaypoint`](#waypoint) objects describing all sources in order.
**`destinations`**: array of [`Ẁaypoint`](#waypoint) objects describing all destinations in order. **`destinations`**: array of [`Ẁaypoint`](#waypoint) objects describing all destinations in order.
**`fallback_speed_cells`**: (optional) if `fallback_speed` is used, will be an array of arrays of `row,column` values, indicating which cells contain estimated values.
### tile ### tile
@@ -173,7 +167,7 @@ and what weights they have applied.
- `ZXY` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** an array consisting of `x`, `y`, and `z` values representing tile coordinates like - `ZXY` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** an array consisting of `x`, `y`, and `z` values representing tile coordinates like
[wiki.openstreetmap.org/wiki/Slippy_map_tilenames](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames) [wiki.openstreetmap.org/wiki/Slippy_map_tilenames](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames)
and are supported by vector tile viewers like [Mapbox GL JS](https://www.mapbox.com/mapbox-gl-js/api/). and are supported by vector tile viewers like [Mapbox GL JS](https://www.mapbox.com/mapbox-gl-js/api/).
- `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**
@@ -210,7 +204,7 @@ 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`).
- `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**
@@ -274,7 +268,7 @@ Right now, the following combinations are possible:
- `options.source` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Return route starts at `any` or `first` coordinate. (optional, default `any`) - `options.source` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Return route starts at `any` or `first` coordinate. (optional, default `any`)
- `options.destination` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Return route ends at `any` or `last` coordinate. (optional, default `any`) - `options.destination` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Return route ends at `any` or `last` coordinate. (optional, default `any`)
- `options.approaches` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`. - `options.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`.
- `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**
@@ -303,39 +297,18 @@ Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer
2) `waypoint_index`: index of the point in the trip. 2) `waypoint_index`: index of the point in the trip.
**`trips`**: an array of [`Route`](#route) objects that assemble the trace. **`trips`**: an array of [`Route`](#route) objects that assemble the trace.
## Plugin behaviour
All plugins support a second additional object that is available to configure some NodeJS specific behaviours.
- `plugin_config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the trip query.
- `plugin_config.format` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** The format of the result object to various API calls. Valid options are `object` (default), which returns a standard Javascript object, as described above, and `json_buffer`, which will return a NodeJS **[Buffer](https://nodejs.org/api/buffer.html)** object, containing a JSON string. The latter has the advantage that it can be immediately serialized to disk/sent over the network, and the generation of the string is performed outside the main NodeJS event loop. This option is ignored by the `tile` plugin.
**Examples**
```javascript
var osrm = new OSRM('network.osrm');
var options = {
coordinates: [
[13.36761474609375, 52.51663871100423],
[13.374481201171875, 52.506191342034576]
]
};
osrm.route(options, { format: "json_buffer" }, function(err, response) {
if (err) throw err;
console.log(response.toString("utf-8"));
});
```
## Responses ## Responses
Responses
### Route ### Route
Represents a route through (potentially multiple) waypoints. Represents a route through (potentially multiple) waypoints.
**Parameters** **Parameters**
- **documentation** in - `exteral` **documentation** in
[`osrm-backend`](../http.md#route-object) [`osrm-backend`](../http.md#route)
### RouteLeg ### RouteLeg
@@ -343,8 +316,8 @@ Represents a route between two waypoints.
**Parameters** **Parameters**
- **documentation** in - `exteral` **documentation** in
[`osrm-backend`](../http.md#routeleg-object) [`osrm-backend`](../http.md#routeleg)
### RouteStep ### RouteStep
@@ -353,15 +326,15 @@ single way to the subsequent step.
**Parameters** **Parameters**
- **documentation** in - `exteral` **documentation** in
[`osrm-backend`](../http.md#routestep-object) [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#routestep)
### StepManeuver ### StepManeuver
**Parameters** **Parameters**
- **documentation** in - `exteral` **documentation** in
[`osrm-backend`](../http.md#stepmaneuver-object) [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#stepmaneuver)
### Waypoint ### Waypoint
@@ -369,5 +342,5 @@ Object used to describe waypoint on a route.
**Parameters** **Parameters**
- **documentation** in - `exteral` **documentation** in
[`osrm-backend`](../http.md#waypoint-object) [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#waypoint)
+2 -2
View File
@@ -138,7 +138,7 @@ Given an OpenStreetMap way, the `process_way` function will either return nothin
Argument | Description Argument | Description
---------|------------------------------------------------------- ---------|-------------------------------------------------------
profile | The configuration table you returned in `setup`. profile | The configuration table you returned in `setup`.
way | The input way to process (read-only). node | The input way to process (read-only).
result | The output that you will modify. result | The output that you will modify.
relations| Storage of relations to access relations, where `way` is a member. relations| Storage of relations to access relations, where `way` is a member.
@@ -199,7 +199,7 @@ source.lon | Read | Float | Co-ordinates of segment start
source.lat | Read | Float | "" source.lat | Read | Float | ""
target.lon | Read | Float | Co-ordinates of segment end target.lon | Read | Float | Co-ordinates of segment end
target.lat | Read | Float | "" target.lat | Read | Float | ""
distance | Read | Float | Length of segment target.distance | Read | Float | Length of segment
weight | Read/write | Float | Routing weight for this segment weight | Read/write | Float | Routing weight for this segment
duration | Read/write | Float | Duration for this segment duration | Read/write | Float | Duration for this segment
+1 -1
View File
@@ -19,7 +19,7 @@ Feature: Barriers
| entrance | x | | entrance | x |
| wall | | | wall | |
| fence | | | fence | |
| some_tag | x | | some_tag | |
| block | x | | block | x |
Scenario: Bike - Access tag trumphs barriers Scenario: Bike - Access tag trumphs barriers
-9
View File
@@ -109,12 +109,3 @@ Feature: Car - Handle ferry routes
When I route I should get When I route I should get
| from | to | route | modes | time | | from | to | route | modes | time |
| c | d | bcde,bcde | ferry,ferry | 600s | | c | d | bcde,bcde | ferry,ferry | 600s |
Given the query options
| geometries | geojson |
| overview | full |
# Note that matching *should* work across unsnappable ferries
When I match I should get
| trace | geometry | duration |
| abcdef| 1,1,1.000899,1,1.000899,1,1.002697,1,1.002697,1,1.003596,1,1.003596,1,1.005394,1,1.005394,1,1.006293,1 | 610.9 |
-25
View File
@@ -137,28 +137,3 @@ OSRM will use 4/5 of the projected free-flow speed.
| primary | | | 30 | -1 | | 23 km/h | | 6.7 | | primary | | | 30 | -1 | | 23 km/h | | 6.7 |
| primary | 20 | 30 | | -1 | | 15 km/h | | 4.4 | | primary | 20 | 30 | | -1 | | 15 km/h | | 4.4 |
| primary | 20 | | 30 | -1 | | 23 km/h | | 6.7 | | primary | 20 | | 30 | -1 | | 23 km/h | | 6.7 |
Scenario: Car - Respect source:maxspeed
Given the node map
"""
a b c d e f g
"""
And the ways
| nodes | highway | source:maxspeed | maxspeed |
| ab | trunk | | |
| bc | trunk | | 60 |
| cd | trunk | FR:urban | |
| de | trunk | CH:rural | |
| ef | trunk | CH:trunk | |
| fg | trunk | CH:motorway | |
When I route I should get
| from | to | route | speed |
| a | b | ab,ab | 85 km/h |
| b | c | bc,bc | 48 km/h |
| c | d | cd,cd | 40 km/h |
| d | e | de,de | 64 km/h |
| e | f | ef,ef | 80 km/h |
| f | g | fg,fg | 96 km/h |
-19
View File
@@ -48,22 +48,3 @@ Feature: Car - Handle physical limitation
| primary | | none | x | | primary | | none | x |
| primary | | no-sign | x | | primary | | no-sign | x |
| primary | | unsigned | x | | primary | | unsigned | x |
Scenario: Car - Limited by length
Then routability should be
| highway | maxlength | bothw |
| primary | | x |
| primary | 1 | |
| primary | 5 | x |
| primary | unsigned | x |
Scenario: Car - Limited by weight
Then routability should be
| highway | maxweight | bothw |
| primary | | x |
| primary | 1 | |
| primary | 3.5 | x |
| primary | 35000 kg | x |
| primary | 8.9t | x |
| primary | 0.1 lbs | |
| primary | unsigned | x |
-25
View File
@@ -35,28 +35,3 @@ Feature: Car - Allowed start/end modes
| from | to | route | modes | | from | to | route | modes |
| 1 | 2 | ab,ab | driving,driving | | 1 | 2 | ab,ab | driving,driving |
| 2 | 1 | ab,ab | driving,driving | | 2 | 1 | ab,ab | driving,driving |
Scenario: Car - URL override of non-startpoints
Given the node map
"""
a 1 b c 2 d
"""
Given the query options
| snapping | any |
And the ways
| nodes | highway | access |
| ab | service | private |
| bc | primary | |
| cd | service | private |
When I request a travel time matrix I should get
| | 2 | c |
| 1 | 59.1 | 35.1 |
| b | 35.1 | 11.1 |
When I route I should get
| from | to | route |
| 1 | 2 | ab,bc,cd |
| 2 | 1 | cd,bc,ab |
-36
View File
@@ -1,36 +0,0 @@
@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 |
+1 -1
View File
@@ -19,7 +19,7 @@ Feature: Barriers
| entrance | x | | entrance | x |
| wall | | | wall | |
| fence | | | fence | |
| some_tag | x | | some_tag | |
| block | x | | block | x |
Scenario: Foot - Access tag trumphs barriers Scenario: Foot - Access tag trumphs barriers
+3 -53
View File
@@ -84,47 +84,7 @@ class OSRMDirectLoader extends OSRMBaseLoader {
throw new Error(util.format('osrm-routed %s: %s', errorReason(err), err.cmd)); throw new Error(util.format('osrm-routed %s: %s', errorReason(err), err.cmd));
} }
}); });
callback();
this.child.readyFunc = (data) => {
if (/running and waiting for requests/.test(data)) {
this.child.stdout.removeListener('data', this.child.readyFunc);
callback();
}
};
this.child.stdout.on('data',this.child.readyFunc);
}
};
class OSRMmmapLoader extends OSRMBaseLoader {
constructor (scope) {
super(scope);
}
load (inputFile, callback) {
this.inputFile = inputFile;
this.shutdown(() => {
this.launch(callback);
});
}
osrmUp (callback) {
if (this.osrmIsRunning()) return callback(new Error("osrm-routed already running!"));
const command_arguments = util.format('%s -p %d -i %s -a %s --mmap', this.inputFile, this.scope.OSRM_PORT, this.scope.OSRM_IP, this.scope.ROUTING_ALGORITHM);
this.child = this.scope.runBin('osrm-routed', command_arguments, this.scope.environment, (err) => {
if (err && err.signal !== 'SIGINT') {
this.child = null;
throw new Error(util.format('osrm-routed %s: %s', errorReason(err), err.cmd));
}
});
this.child.readyFunc = (data) => {
if (/running and waiting for requests/.test(data)) {
this.child.stdout.removeListener('data', this.child.readyFunc);
callback();
}
};
this.child.stdout.on('data',this.child.readyFunc);
} }
}; };
@@ -175,32 +135,22 @@ class OSRMLoader {
this.scope = scope; this.scope = scope;
this.sharedLoader = new OSRMDatastoreLoader(this.scope); this.sharedLoader = new OSRMDatastoreLoader(this.scope);
this.directLoader = new OSRMDirectLoader(this.scope); this.directLoader = new OSRMDirectLoader(this.scope);
this.mmapLoader = new OSRMmmapLoader(this.scope);
this.method = scope.DEFAULT_LOAD_METHOD; this.method = scope.DEFAULT_LOAD_METHOD;
} }
load (inputFile, callback) { load (inputFile, callback) {
if (!this.loader) {
this.loader = {shutdown: (cb) => cb() };
}
if (this.method === 'datastore') { if (this.method === 'datastore') {
this.loader.shutdown((err) => { this.directLoader.shutdown((err) => {
if (err) return callback(err); if (err) return callback(err);
this.loader = this.sharedLoader; this.loader = this.sharedLoader;
this.sharedLoader.load(inputFile, callback); this.sharedLoader.load(inputFile, callback);
}); });
} else if (this.method === 'directly') { } else if (this.method === 'directly') {
this.loader.shutdown((err) => { this.sharedLoader.shutdown((err) => {
if (err) return callback(err); if (err) return callback(err);
this.loader = this.directLoader; this.loader = this.directLoader;
this.directLoader.load(inputFile, callback); this.directLoader.load(inputFile, callback);
}); });
} else if (this.method === 'mmap') {
this.loader.shutdown((err) => {
if (err) return callback(err);
this.loader = this.mmapLoader;
this.mmapLoader.load(inputFile, callback);
});
} else { } else {
callback(new Error('*** Unknown load method ' + method)); callback(new Error('*** Unknown load method ' + method));
} }
+1 -1
View File
@@ -295,7 +295,7 @@ module.exports = function () {
this.reprocess(callback); this.reprocess(callback);
}); });
this.Given(/^osrm-routed is stopped$/, (callback) => { this.Given(/^osrm\-routed is stopped$/, (callback) => {
this.OSRMLoader.shutdown(callback); this.OSRMLoader.shutdown(callback);
}); });
+7 -25
View File
@@ -3,25 +3,22 @@ var util = require('util');
module.exports = function () { module.exports = function () {
const durationsRegex = new RegExp(/^I request a travel time matrix I should get$/); const durationsRegex = new RegExp(/^I request a travel time matrix I should get$/);
const distancesRegex = new RegExp(/^I request a travel distance matrix I should get$/); const distancesRegex = new RegExp(/^I request a travel distance matrix I should get$/);
const estimatesRegex = new RegExp(/^I request a travel time matrix I should get estimates for$/);
const DURATIONS_NO_ROUTE = 2147483647; // MAX_INT const DURATIONS_NO_ROUTE = 2147483647; // MAX_INT
const DISTANCES_NO_ROUTE = 3.40282e+38; // MAX_FLOAT const DISTANCES_NO_ROUTE = 3.40282e+38; // MAX_FLOAT
this.When(durationsRegex, function(table, callback) {tableParse.call(this, table, DURATIONS_NO_ROUTE, 'durations', callback);}.bind(this)); this.When(durationsRegex, function(table, callback) {tableParse.call(this, table, DURATIONS_NO_ROUTE, 'durations', callback);}.bind(this));
this.When(distancesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'distances', callback);}.bind(this)); this.When(distancesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'distances', callback);}.bind(this));
this.When(estimatesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'fallback_speed_cells', callback);}.bind(this));
}; };
const durationsParse = function(v) { return isNaN(parseInt(v)); }; const durationsParse = function(v) { return isNaN(parseInt(v)); };
const distancesParse = function(v) { return isNaN(parseFloat(v)); }; const distancesParse = function(v) { return isNaN(parseFloat(v)); };
const estimatesParse = function(v) { return isNaN(parseFloat(v)); };
function tableParse(table, noRoute, annotation, callback) { function tableParse(table, noRoute, annotation, callback) {
const parse = annotation == 'distances' ? distancesParse : (annotation == 'durations' ? durationsParse : estimatesParse); const parse = annotation == 'distances' ? distancesParse : durationsParse;
const params = this.queryParams; const params = this.queryParams;
params.annotations = ['durations','fallback_speed_cells'].indexOf(annotation) !== -1 ? 'duration' : 'distance'; params.annotations = annotation == 'distances' ? 'distance' : 'duration';
var tableRows = table.raw(); var tableRows = table.raw();
@@ -64,26 +61,11 @@ function tableParse(table, noRoute, annotation, callback) {
var json = JSON.parse(response.body); var json = JSON.parse(response.body);
var result = {}; var result = json[annotation].map(row => {
if (annotation === 'fallback_speed_cells') { var hashes = {};
result = table.raw().map(row => row.map(() => '')); row.forEach((v, i) => { hashes[tableRows[0][i+1]] = parse(v) ? '' : v; });
json[annotation].forEach(pair => { return hashes;
result[pair[0]+1][pair[1]+1] = 'Y'; });
});
result = result.slice(1).map(row => {
var hashes = {};
row.slice(1).forEach((v,i) => {
hashes[tableRows[0][i+1]] = v;
});
return hashes;
});
} else {
result = json[annotation].map(row => {
var hashes = {};
row.forEach((v, i) => { hashes[tableRows[0][i+1]] = parse(v) ? '' : v; });
return hashes;
});
}
var testRow = (row, ri, cb) => { var testRow = (row, ri, cb) => {
for (var k in result[ri]) { for (var k in result[ri]) {
+6 -6
View File
@@ -21,11 +21,11 @@ module.exports = function () {
}); });
}; };
this.When(/^I run "osrm-routed\s?(.*?)"$/, { timeout: this.TIMEOUT }, (options, callback) => { this.When(/^I run "osrm\-routed\s?(.*?)"$/, { timeout: this.TIMEOUT }, (options, callback) => {
this.runAndSafeOutput('osrm-routed', options, callback); this.runAndSafeOutput('osrm-routed', options, callback);
}); });
this.When(/^I run "osrm-(extract|contract|partition|customize)\s?(.*?)"$/, (binary, options, callback) => { this.When(/^I run "osrm\-(extract|contract|partition|customize)\s?(.*?)"$/, (binary, options, callback) => {
const stamp = this.processedCacheFile + '.stamp_' + binary; const stamp = this.processedCacheFile + '.stamp_' + binary;
this.runAndSafeOutput('osrm-' + binary, options, (err) => { this.runAndSafeOutput('osrm-' + binary, options, (err) => {
if (err) return callback(err); if (err) return callback(err);
@@ -33,11 +33,11 @@ module.exports = function () {
}); });
}); });
this.When(/^I try to run "(osrm-[a-z]+)\s?(.*?)"$/, (binary, options, callback) => { this.When(/^I try to run "(osrm\-[a-z]+)\s?(.*?)"$/, (binary, options, callback) => {
this.runAndSafeOutput(binary, options, () => { callback(); }); this.runAndSafeOutput(binary, options, () => { callback(); });
}); });
this.When(/^I run "osrm-datastore\s?(.*?)"(?: with input "([^"]*)")?$/, (options, input, callback) => { this.When(/^I run "osrm\-datastore\s?(.*?)"(?: with input "([^"]*)")?$/, (options, input, callback) => {
let child = this.runAndSafeOutput('osrm-datastore', options, callback); let child = this.runAndSafeOutput('osrm-datastore', options, callback);
if (input !== undefined) if (input !== undefined)
child.stdin.write(input); child.stdin.write(input);
@@ -55,13 +55,13 @@ module.exports = function () {
this.Then(/^stdout should( not)? contain "(.*?)"$/, (not, str) => { this.Then(/^stdout should( not)? contain "(.*?)"$/, (not, str) => {
const contains = this.stdout.indexOf(str) > -1; const contains = this.stdout.indexOf(str) > -1;
assert.ok(typeof not === 'undefined' ? contains : !contains, assert.ok(typeof not === 'undefined' ? contains : !contains,
'stdout ' + (typeof not === 'undefined' ? 'does not contain' : 'contains') + ' "' + str + '"'); 'stdout ' + (typeof not === 'undefined' ? 'does not contain' : 'contains') + ' "' + str + '"');
}); });
this.Then(/^stderr should( not)? contain "(.*?)"$/, (not, str) => { this.Then(/^stderr should( not)? contain "(.*?)"$/, (not, str) => {
const contains = this.stderr.indexOf(str) > -1; const contains = this.stderr.indexOf(str) > -1;
assert.ok(typeof not === 'undefined' ? contains : !contains, assert.ok(typeof not === 'undefined' ? contains : !contains,
'stderr ' + (typeof not === 'undefined' ? 'does not contain' : 'contains') + ' "' + str + '"'); 'stderr ' + (typeof not === 'undefined' ? 'does not contain' : 'contains') + ' "' + str + '"');
}); });
this.Then(/^stdout should contain \/(.*)\/$/, (regexStr) => { this.Then(/^stdout should contain \/(.*)\/$/, (regexStr) => {
+1 -1
View File
@@ -69,7 +69,7 @@ module.exports = function () {
outputRow[direction] = result[direction].status ? outputRow[direction] = result[direction].status ?
'x' : ''; 'x' : '';
break; break;
case /^[\d.]+ s/.test(want): case /^[\d\.]+ s/.test(want):
// the result here can come back as a non-number value like // the result here can come back as a non-number value like
// `diff`, but we only want to apply the unit when it comes // `diff`, but we only want to apply the unit when it comes
// back as a number, for tableDiff's literal comparison // back as a number, for tableDiff's literal comparison
+7 -7
View File
@@ -29,7 +29,7 @@ module.exports = function() {
// setup cache for feature data // setup cache for feature data
// if OSRM_PROFILE is set to force a specific profile, then // if OSRM_PROFILE is set to force a specific profile, then
// include the profile name in the hash of the profile file // include the profile name in the hash of the profile file
hash.hashOfFile(uri, this.OSRM_PROFILE, (err, hash) => { hash.hashOfFile(uri, this.OSRM_PROFILE, (err, hash) => {
if (err) return callback(err); if (err) return callback(err);
@@ -45,10 +45,10 @@ module.exports = function() {
this.featureProcessedCacheDirectories[uri] = featureProcessedCacheDirectory; this.featureProcessedCacheDirectories[uri] = featureProcessedCacheDirectory;
d3.queue(1) d3.queue(1)
.defer(mkdirp, featureProcessedCacheDirectory) .defer(mkdirp, featureProcessedCacheDirectory)
.defer(this.cleanupFeatureCache.bind(this), featureCacheDirectory, hash) .defer(this.cleanupFeatureCache.bind(this), featureCacheDirectory, hash)
.defer(this.cleanupProcessedFeatureCache.bind(this), featureProcessedCacheDirectory, this.osrmHash) .defer(this.cleanupProcessedFeatureCache.bind(this), featureProcessedCacheDirectory, this.osrmHash)
.awaitAll(callback); .awaitAll(callback);
}); });
} }
@@ -87,7 +87,7 @@ module.exports = function() {
fs.readdir(parentPath, (err, files) => { fs.readdir(parentPath, (err, files) => {
let q = d3.queue(); let q = d3.queue();
files.filter(name => { return name !== featureHash;}) files.filter(name => { return name !== featureHash;})
.map((f) => { q.defer(rimraf, path.join(parentPath, f)); }); .map((f) => { q.defer(rimraf, path.join(parentPath, f)); });
q.awaitAll(callback); q.awaitAll(callback);
}); });
}; };
@@ -145,7 +145,7 @@ module.exports = function() {
// converts the scenario titles in file prefixes // converts the scenario titles in file prefixes
this.getScenarioID = (scenario) => { this.getScenarioID = (scenario) => {
let name = scenario.getName().toLowerCase().replace(/[/\-'=,():*#]/g, '') let name = scenario.getName().toLowerCase().replace(/[\/\-'=,\(\):\*#]/g, '')
.replace(/\s/g, '_').replace(/__/g, '_').replace(/\.\./g, '.') .replace(/\s/g, '_').replace(/__/g, '_').replace(/\.\./g, '.')
.substring(0, 64); .substring(0, 64);
return util.format('%d_%s', scenario.getLine(), name); return util.format('%d_%s', scenario.getLine(), name);
+10 -10
View File
@@ -17,12 +17,12 @@ module.exports = {
return true; return true;
var matchPercent = want.match(/(.*)\s+~(.+)%$/), var matchPercent = want.match(/(.*)\s+~(.+)%$/),
matchAbs = want.match(/(.*)\s+\+-(.+)$/), matchAbs = want.match(/(.*)\s+\+\-(.+)$/),
matchRe = want.match(/^\/(.*)\/$/), matchRe = want.match(/^\/(.*)\/$/),
// we use this for matching before/after bearing // we use this for matching before/after bearing
matchBearingListAbs = want.match(/^((\d+)->(\d+))(,(\d+)->(\d+))*\s+\+-(.+)$/), matchBearingListAbs = want.match(/^((\d+)->(\d+))(,(\d+)->(\d+))*\s+\+\-(.+)$/),
matchIntersectionListAbs = want.match(/^(((((true|false):\d+)\s{0,1})+,{0,1})+;{0,1})+\s+\+-(.+)$/), matchIntersectionListAbs = want.match(/^(((((true|false):\d+)\s{0,1})+,{0,1})+;{0,1})+\s+\+\-(.+)$/),
matchRangeNumbers = want.match(/\d+\+-\d+/); matchRangeNumbers = want.match(/\d+\+\-\d+/);
function inRange(margin, got, want) { function inRange(margin, got, want) {
var fromR = parseFloat(want) - margin, var fromR = parseFloat(want) - margin,
@@ -31,12 +31,12 @@ module.exports = {
} }
function parseIntersectionString(str) { function parseIntersectionString(str) {
return str.split(';') return str.split(';')
.map((turn_intersections) => turn_intersections .map((turn_intersections) => turn_intersections
.split(',') .split(',')
.map((intersection) => intersection .map((intersection) => intersection
.split(' ') .split(' ')
.map((entry_bearing_pair) => entry_bearing_pair .map((entry_bearing_pair) => entry_bearing_pair
.split(':')))); .split(':'))));
} }
if (got === want) { if (got === want) {
+2 -2
View File
@@ -32,7 +32,7 @@ module.exports = function () {
this.DEFAULT_ENVIRONMENT = Object.assign({STXXLCFG: stxxl_config}, process.env); this.DEFAULT_ENVIRONMENT = Object.assign({STXXLCFG: stxxl_config}, process.env);
this.DEFAULT_PROFILE = 'bicycle'; this.DEFAULT_PROFILE = 'bicycle';
this.DEFAULT_INPUT_FORMAT = 'osm'; this.DEFAULT_INPUT_FORMAT = 'osm';
this.DEFAULT_LOAD_METHOD = process.argv[process.argv.indexOf('-m') +1].match('mmap') ? 'mmap' : 'datastore'; this.DEFAULT_LOAD_METHOD = 'datastore';
this.DEFAULT_ORIGIN = [1,1]; this.DEFAULT_ORIGIN = [1,1];
this.OSM_USER = 'osrm'; this.OSM_USER = 'osrm';
this.OSM_UID = 1; this.OSM_UID = 1;
@@ -80,7 +80,7 @@ module.exports = function () {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.info(util.format('Node Version', process.version)); console.info(util.format('Node Version', process.version));
if (parseInt(process.version.match(/v(\d+)/)[1]) < 4) throw new Error('*** Please upgrade to Node 4.+ to run OSRM cucumber tests'); if (parseInt(process.version.match(/v(\d)/)[1]) < 4) throw new Error('*** Please upgrade to Node 4.+ to run OSRM cucumber tests');
fs.exists(this.TEST_PATH, (exists) => { fs.exists(this.TEST_PATH, (exists) => {
if (exists) if (exists)
+2 -2
View File
@@ -115,7 +115,7 @@ module.exports = function () {
if (headers.has('weight')) { if (headers.has('weight')) {
if (row.weight.length) { if (row.weight.length) {
if (!row.weight.match(/[\d.]+/)) if (!row.weight.match(/[\d\.]+/))
return cb(new Error('*** Weight must be specified as a numeric value. (ex: 8)')); return cb(new Error('*** Weight must be specified as a numeric value. (ex: 8)'));
got.weight = instructions ? util.format('%d', weight) : ''; got.weight = instructions ? util.format('%d', weight) : '';
} else { } else {
@@ -151,7 +151,7 @@ module.exports = function () {
if (headers.has('locations')){ if (headers.has('locations')){
got.locations = (locations || '').trim(); got.locations = (locations || '').trim();
} }
/* /*
if (headers.has('approaches')){ if (headers.has('approaches')){
got.approaches = (approaches || '').trim(); got.approaches = (approaches || '').trim();
}*/ }*/
+135 -291
View File
@@ -5,49 +5,21 @@ Feature: Basic Distance Matrix
Background: Background:
Given the profile "testbot" Given the profile "testbot"
And the partition extra arguments "--small-component-size 1 --max-cell-sizes 2,4,8,16" And the partition extra arguments "--small-component-size 1 --max-cell-sizes 2,4,8,16"
Scenario: Testbot - Travel distance matrix of small grid
Scenario: Testbot - Travel distance matrix of minimal network
Given the node map Given the node map
""" """
a b c a b
d e f
""" """
And the ways And the ways
| nodes | | nodes |
| abc | | ab |
| def |
| ad |
| be |
| cf |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | e | f | | | a | b |
| a | 0 | 100.1 | 199.5 | 299.5 | | a | 0 | 100+-1 |
| b | 100.1 | 0 | 99.4 | 199.5 | | b | 100+-1 | 0 |
| e | 199.5 | 99.4 | 0 | 100.1 |
| f | 299.5 | 199.5 | 100.1 | 0 |
Scenario: Testbot - Travel distance matrix of minimal network exact distances
Given the node map
"""
a z
b
c
d
"""
And the ways
| nodes |
| az |
| zbcd |
When I request a travel distance matrix I should get
| | a | z | b | c | d |
| a | 0 | 100.1 | 199.5 | 298.9 | 398.3 |
| z | 100.1 | 0 | 99.4 | 198.8 | 298.2 |
| b | 199.5 | 99.4 | 0 | 99.4 | 198.8 |
| c | 298.9 | 198.8 | 99.4 | 0 | 99.4 |
| d | 398.3 | 298.2 | 198.8 | 99.4 | 0 |
Scenario: Testbot - Travel distance matrix of minimal network with toll exclude Scenario: Testbot - Travel distance matrix of minimal network with toll exclude
Given the query options Given the query options
@@ -67,11 +39,11 @@ Feature: Basic Distance Matrix
| bd | motorway | yes | not drivable for exclude=toll and exclude=motorway,toll | | bd | motorway | yes | not drivable for exclude=toll and exclude=motorway,toll |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | c | d | | | a | b | c | d |
| a | 0 | 100.1 | | | | a | 0 | 100+-1 | | |
| b | 100.1 | 0 | | | | b | 100+-1 | 0 | | |
| c | | | 0 | 100.1 | | c | | | 0 | 100+-1 |
| d | | | 100.1 | 0 | | d | | | 100+-1 | 0 |
Scenario: Testbot - Travel distance matrix of minimal network with motorway exclude Scenario: Testbot - Travel distance matrix of minimal network with motorway exclude
Given the query options Given the query options
@@ -91,8 +63,8 @@ Feature: Basic Distance Matrix
| bd | residential | | | bd | residential | |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | c | d | | | a | b | c | d |
| a | 0 | 298.9 | 99.4 | 199.5 | | a | 0 | 300+-2 | 100+-2 | 200+-2 |
Scenario: Testbot - Travel distance matrix of minimal network disconnected motorway exclude Scenario: Testbot - Travel distance matrix of minimal network disconnected motorway exclude
Given the query options Given the query options
@@ -112,8 +84,8 @@ Feature: Basic Distance Matrix
| efgh | residential | | | efgh | residential | |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | e | | | a | b | e |
| a | 0 | 50.1 | | | a | 0 | 50+-1 | |
Scenario: Testbot - Travel distance matrix of minimal network with motorway and toll excludes Scenario: Testbot - Travel distance matrix of minimal network with motorway and toll excludes
Given the query options Given the query options
@@ -134,7 +106,7 @@ Feature: Basic Distance Matrix
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | e | g | | | a | b | e | g |
| a | 0 | 100.1 | | | | a | 0 | 100+-1 | | |
Scenario: Testbot - Travel distance matrix with different way speeds Scenario: Testbot - Travel distance matrix with different way speeds
Given the node map Given the node map
@@ -149,22 +121,22 @@ Feature: Basic Distance Matrix
| cd | tertiary | | cd | tertiary |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | c | d | | | a | b | c | d |
| a | 0 | 100.1 | 200.1 | 300.2 | | a | 0 | 100+-1 | 200+-1 | 300+-1 |
| b | 100.1 | 0 | 100.1 | 200.1 | | b | 100+-1 | 0 | 100+-1 | 200+-1 |
| c | 200.1 | 100.1 | 0 | 100.1 | | c | 200+-1 | 100+-1 | 0 | 100+-1 |
| d | 300.2 | 200.1 | 100.1 | 0 | | d | 300+-1 | 200+-1 | 100+-1 | 0 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | c | d | | | a | b | c | d |
| a | 0 | 100.1 | 200.1 | 300.2 | | a | 0 | 100+-1 | 200+-1 | 300+-1 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | | | a |
| a | 0 | | a | 0 |
| b | 100.1 | | b | 100+-1 |
| c | 200.1 | | c | 200+-1 |
| d | 300.2 | | d | 300+-1 |
Scenario: Testbot - Travel distance matrix of small grid Scenario: Testbot - Travel distance matrix of small grid
Given the node map Given the node map
@@ -182,11 +154,11 @@ Feature: Basic Distance Matrix
| cf | | cf |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | e | f | | | a | b | e | f |
| a | 0 | 100.1 | 199.5 | 299.5 | | a | 0 | 100+-1 | 200+-1 | 300+-1 |
| b | 100.1 | 0 | 99.4 | 199.5 | | b | 100+-1 | 0 | 100+-1 | 200+-1 |
| e | 199.5 | 99.4 | 0 | 100.1 | | e | 200+-1 | 100+-1 | 0 | 100+-1 |
| f | 299.5 | 199.5 | 100.1 | 0 | | f | 300+-1 | 200+-1 | 100+-1 | 0 |
Scenario: Testbot - Travel distance matrix of network with unroutable parts Scenario: Testbot - Travel distance matrix of network with unroutable parts
Given the node map Given the node map
@@ -200,7 +172,7 @@ Feature: Basic Distance Matrix
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | | | a | b |
| a | 0 | 100.1 | | a | 0 | 100+-1 |
| b | | 0 | | b | | 0 |
Scenario: Testbot - Travel distance matrix of network with oneways Scenario: Testbot - Travel distance matrix of network with oneways
@@ -217,11 +189,11 @@ Feature: Basic Distance Matrix
| by | | | by | |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | x | y | d | e | | | x | y | d | e |
| x | 0 | 300.2 | 399.6 | 299.5 | | x | 0 | 300+-2 | 400+-2 | 300+-2 |
| y | 499 | 0 | 299.5 | 199.5 | | y | 500+-2 | 0 | 300+-2 | 200+-2 |
| d | 199.5 | 299.5 | 0 | 298.9 | | d | 200+-2 | 300+-2 | 0 | 300+-2 |
| e | 299.5 | 399.6 | 100.1 | 0 | | e | 300+-2 | 400+-2 | 100+-2 | 0 |
Scenario: Testbot - Rectangular travel distance matrix Scenario: Testbot - Rectangular travel distance matrix
Given the node map Given the node map
@@ -240,53 +212,53 @@ Feature: Basic Distance Matrix
When I route I should get When I route I should get
| from | to | distance | | from | to | distance |
| e | a | 200m | | e | a | 200m +- 1 |
| e | b | 100m | | e | b | 100m +- 1 |
| f | a | 299.9m | | f | a | 300m +- 1 |
| f | b | 200m | | f | b | 200m +- 1 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | e | f | | | a | b | e | f |
| a | 0 | 100.1 | 199.5 | 299.5 | | a | 0 | 100+-1 | 200+-1 | 300+-1 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | | | a |
| a | 0 | | a | 0 |
| b | 100.1 | | b | 100+-1 |
| e | 199.5 | | e | 200+-1 |
| f | 299.5 | | f | 300+-1 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | e | f | | | a | b | e | f |
| a | 0 | 100.1 | 199.5 | 299.5 | | a | 0 | 100+-1 | 200+-1 | 300+-1 |
| b | 100.1 | 0 | 99.4 | 199.5 | | b | 100+-1 | 0 | 100+-1 | 200+-1 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | | | a | b |
| a | 0 | 100.1 | | a | 0 | 100+-1 |
| b | 100.1 | 0 | | b | 100+-1 | 0 |
| e | 199.5 | 99.4 | | e | 200+-1 | 100+-1 |
| f | 299.5 | 199.5 | | f | 300+-1 | 200+-1 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | e | f | | | a | b | e | f |
| a | 0 | 100.1 | 199.5 | 299.5 | | a | 0 | 100+-1 | 200+-1 | 300+-1 |
| b | 100.1 | 0 | 99.4 | 199.5 | | b | 100+-1 | 0 | 100+-1 | 200+-1 |
| e | 199.5 | 99.4 | 0 | 100.1 | | e | 200+-1 | 100+-1 | 0 | 100+-1 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | e | | | a | b | e |
| a | 0 | 100.1 | 199.5 | | a | 0 | 100+-1 | 200+-1 |
| b | 100.1 | 0 | 99.4 | | b | 100+-1 | 0 | 100+-1 |
| e | 199.5 | 99.4 | 0 | | e | 200+-1 | 100+-1 | 0 |
| f | 299.5 | 199.5 | 100.1 | | f | 300+-1 | 200+-1 | 100+-1 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | e | f | | | a | b | e | f |
| a | 0 | 100.1 | 199.5 | 299.5 | | a | 0 | 100+-1 | 200+-1 | 300+-1 |
| b | 100.1 | 0 | 99.4 | 199.5 | | b | 100+-1 | 0 | 100+-1 | 200+-1 |
| e | 199.5 | 99.4 | 0 | 100.1 | | e | 200+-1 | 100+-1 | 0 | 100+-1 |
| f | 299.5 | 199.5 | 100.1 | 0 | | f | 300+-1 | 200+-1 | 100+-1 | 0 |
Scenario: Testbot - Travel distance 3x2 matrix Scenario: Testbot - Travel distance 3x2 matrix
Given the node map Given the node map
@@ -305,9 +277,9 @@ Feature: Basic Distance Matrix
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | b | e | f | | | b | e | f |
| a | 100.1 | 199.5 | 299.5 | | a | 100+-1 | 200+-1 | 300+-1 |
| b | 0 | 99.4 | 199.5 | | b | 0 | 100+-1 | 200+-1 |
Scenario: Testbot - All coordinates are from same small component Scenario: Testbot - All coordinates are from same small component
Given a grid size of 300 meters Given a grid size of 300 meters
@@ -327,9 +299,9 @@ Feature: Basic Distance Matrix
| fg | | fg |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | f | g | | | f | g |
| f | 0 | 298.2 | | f | 0 | 300+-2 |
| g | 298.2 | 0 | | g | 300+-2 | 0 |
Scenario: Testbot - Coordinates are from different small component and snap to big CC Scenario: Testbot - Coordinates are from different small component and snap to big CC
Given a grid size of 300 meters Given a grid size of 300 meters
@@ -361,11 +333,11 @@ Feature: Basic Distance Matrix
| i | h | 300m | | i | h | 300m |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | f | g | h | i | | | f | g | h | i |
| f | 0 | 298.2 | 0 | 298.2 | | f | 0 | 300+-2 | 0 | 300+-2 |
| g | 298.2 | 0 | 298.2 | 0 | | g | 300+-2 | 0 | 300+-2 | 0 |
| h | 0 | 298.2 | 0 | 298.2 | | h | 0 | 300+-2 | 0 | 300+-2 |
| i | 298.2 | 0 | 298.2 | 0 | | i | 300+-2 | 0 | 300+-2 | 0 |
Scenario: Testbot - Travel distance matrix with loops Scenario: Testbot - Travel distance matrix with loops
Given the node map Given the node map
@@ -382,11 +354,11 @@ Feature: Basic Distance Matrix
| da | yes | | da | yes |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | 1 | 2 | 3 | 4 | | | 1 | 2 | 3 | 4 |
| 1 | 0 | 100.1 | 399.6 | 499.7 | | 1 | 0 | 100+-1 | 400+-1 | 500+-1 |
| 2 | 699.1 | 0 | 299.5 | 399.6 | | 2 | 700+-1 | 0 | 300+-1 | 400+-1 |
| 3 | 399.6 | 499.7 | 0 | 100.1 | | 3 | 400+-1 | 500+-1 | 0 | 100+-1 |
| 4 | 299.5 | 399.6 | 699.1 | 0 | | 4 | 300+-1 | 400+-1 | 700+-1 | 0 |
Scenario: Testbot - Travel distance matrix based on segment durations Scenario: Testbot - Travel distance matrix based on segment durations
@@ -423,12 +395,12 @@ Feature: Basic Distance Matrix
| ce | | ce |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | c | d | e | | | a | b | c | d | e |
| a | 0 | 100.1 | 200.1 | 300.2 | 398.9 | | a | 0 | 100+-2 | 200+-2 | 300+-2 | 400+-2 |
| b | 100.1 | 0 | 100.1 | 200.1 | 298.9 | | b | 100+-2 | 0 | 100+-2 | 200+-2 | 300+-2 |
| c | 200.1 | 100.1 | 0 | 100.1 | 198.8 | | c | 200+-2 | 100+-2 | 0 | 100+-2 | 200+-2 |
| d | 300.2 | 200.1 | 100.1 | 0 | 298.9 | | d | 300+-2 | 200+-2 | 100+-2 | 0 | 300+-2 |
| e | 398.9 | 298.9 | 198.8 | 298.9 | 0 | | e | 400+-2 | 300+-2 | 200+-2 | 300+-2 | 0 |
Scenario: Testbot - Travel distance matrix for alternative loop paths Scenario: Testbot - Travel distance matrix for alternative loop paths
Given the profile file Given the profile file
@@ -467,26 +439,26 @@ Feature: Basic Distance Matrix
| ca | yes | | ca | yes |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 1 | 0 | 1096.7 | 298.9 | 199.5 | 598.4 | 498.3 | 897.3 | 797.9 | | 1 | 0 | 1100+-5 | 300+-5 | 200+-5 | 600+-5 | 500+-5 | 900+-5 | 800+-5 |
| 2 | 100.1 | 0 | 398.9 | 299.5 | 698.5 | 598.4 | 997.3 | 897.9 | | 2 | 100+-5 | 0 | 400+-5 | 300+-5 | 700+-5 | 600+-5 | 1000+-5 | 900+-5 |
| 3 | 897.9 | 797.9 | 0 | 1097.4 | 299.5 | 199.5 | 598.4 | 499 | | 3 | 900+-5 | 800+-5 | 0 | 1100+-5 | 300+-5 | 200+-5 | 600+-5 | 500+-5 |
| 4 | 997.3 | 897.3 | 99.4 | 0 | 398.9 | 298.9 | 697.8 | 598.4 | | 4 | 1000+-5 | 900+-5 | 100+-5 | 0 | 400+-5 | 300+-5 | 700+-5 | 600+-5 |
| 5 | 598.4 | 498.3 | 897.3 | 797.9 | 0 | 1096.7 | 298.9 | 199.5 | | 5 | 600+-5 | 500+-5 | 900+-5 | 800+-5 | 0 | 1100+-5 | 300+-5 | 200+-5 |
| 6 | 698.5 | 598.4 | 997.3 | 897.9 | 100.1 | 0 | 398.9 | 299.5 | | 6 | 700+-5 | 600+-5 | 1000+-5 | 900+-5 | 100+-5 | 0 | 400+-5 | 300+-5 |
| 7 | 299.5 | 199.5 | 598.4 | 499 | 897.9 | 797.9 | 0 | 1097.4 | | 7 | 300+-5 | 200+-5 | 600+-5 | 500+-5 | 900+-5 | 800+-5 | 0 | 1100+-5 |
| 8 | 398.9 | 298.9 | 697.8 | 598.4 | 997.3 | 897.3 | 99.4 | 0 | | 8 | 400+-5 | 300+-5 | 700+-5 | 600+-5 | 1000+-5 | 900+-5 | 100+-5 | 0 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | 1 | | | 1 |
| 1 | 0 | | 1 | 0 |
| 2 | 100.1 | | 2 | 100+-5 |
| 3 | 897.9 | | 3 | 900+-5 |
| 4 | 997.3 | | 4 | 1000+-5 |
| 5 | 598.4 | | 5 | 600+-5 |
| 6 | 698.5 | | 6 | 700+-5 |
| 7 | 299.5 | | 7 | 300+-5 |
| 8 | 398.9 | | 8 | 400+-5 |
Scenario: Testbot - Travel distance matrix with ties Scenario: Testbot - Travel distance matrix with ties
Given the node map Given the node map
@@ -508,26 +480,26 @@ Feature: Basic Distance Matrix
| a | c | ac,ac | 200m | 20s | 20 | | a | c | ac,ac | 200m | 20s | 20 |
When I route I should get When I route I should get
| from | to | route | distance | | from | to | route | distance |
| a | b | ab,ab | 450m | | a | b | ab,ab | 450m |
| a | c | ac,ac | 200m | | a | c | ac,ac | 200m |
| a | d | ac,dc,dc | 499.9m | | a | d | ac,dc,dc | 500m +- 1 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | c | d | | | a | b | c | d |
| a | 0 | 450.3 | 198.8 | 499 | | a | 0 | 450+-2 | 200+-2 | 500+-2 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | | | a |
| a | 0 | | a | 0 |
| b | 450.3 | | b | 450+-2 |
| c | 198.8 | | c | 200+-2 |
| d | 499 | | d | 500+-2 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | c | | | a | c |
| a | 0 | 198.8 | | a | 0 | 200+-2 |
| c | 198.8 | 0 | | c | 200+-2 | 0 |
# Check rounding errors # Check rounding errors
@@ -543,8 +515,8 @@ Feature: Basic Distance Matrix
| abcd | | abcd |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | c | d | | | a | b | c | d |
| a | 0 | 1000.7 | 2001.4 | 3002.1 | | a | 0 | 1000+-3 | 2000+-3 | 3000+-3 |
Scenario: Testbot - OneToMany vs ManyToOne Scenario: Testbot - OneToMany vs ManyToOne
@@ -588,138 +560,10 @@ Feature: Basic Distance Matrix
| fd | | | fd | |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | b | c | d | e | f | | | a | b | c | d | e | f |
| a | 0 | 100.1 | 300.2 | 650.5 | 1930.6 | 1533 | | a | 0 | 100+-1 | 300+-1 | 650+-1 | 1930+-1 | 1533+-1 |
| b | 759 | 0 | 200.1 | 550.4 | 1830.5 | 1432.9 | | b | 760+-1 | 0 | 200+-1 | 550+-1 | 1830+-1 | 1433+-1 |
| c | 558.8 | 658.9 | 0 | 350.3 | 1630.4 | 1232.8 | | c | 560+-2 | 660+-2 | 0 | 350+-1 | 1630+-1 | 1233+-1 |
| d | 1478.9 | 1579 | 1779.1 | 0 | 1280.1 | 882.5 | | d | 1480+-2 | 1580+-1 | 1780+-1 | 0 | 1280+-1 | 883+-1 |
| e | 198.8 | 298.9 | 499 | 710.3 | 0 | 1592.8 | | e | 200+-2 | 300+-2 | 500+-1 | 710+-1 | 0 | 1593+-1 |
| f | 596.4 | 696.5 | 896.6 | 1107.9 | 397.6 | 0 | | f | 597+-1 | 696+-1 | 896+-1 | 1108+-1 | 400+-3 | 0 |
Scenario: Testbot - Filling in noroutes with estimates (defaults to input coordinate location)
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the query options
| fallback_speed | 5 |
Given the node map
"""
a b f h 1
d e g i
"""
And the ways
| nodes |
| abeda |
| fhigf |
When I request a travel distance matrix I should get
| | a | b | f | 1 |
| a | 0 | 300.2 | 900.7 | 1501.1 |
| b | 300.2 | 0 | 600.5 | 1200.9 |
| f | 900.7 | 600.5 | 0 | 300.2 |
| 1 | 1501.1 | 1200.9 | 300.2 | 0 |
When I request a travel distance matrix I should get
| | a | b | f | 1 |
| a | 0 | 300.2 | 900.7 | 1501.1 |
When I request a travel distance matrix I should get
| | a |
| a | 0 |
| b | 300.2 |
| f | 900.7 |
| 1 | 1501.1 |
Scenario: Testbot - Fise input coordinate
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the query options
| fallback_speed | 5 |
| fallback_coordinate | input |
Given the node map
"""
a b f h 1
d e g i
"""
And the ways
| nodes |
| abeda |
| fhigf |
When I request a travel distance matrix I should get
| | a | b | f | 1 |
| a | 0 | 300.2 | 900.7 | 1501.1 |
| b | 300.2 | 0 | 600.5 | 1200.9 |
| f | 900.7 | 600.5 | 0 | 300.2 |
| 1 | 1501.1 | 1200.9 | 300.2 | 0 |
When I request a travel distance matrix I should get
| | a | b | f | 1 |
| a | 0 | 300.2 | 900.7 | 1501.1 |
When I request a travel distance matrix I should get
| | a |
| a | 0 |
| b | 300.2 |
| f | 900.7 |
| 1 | 1501.1 |
Scenario: Testbot - Filling in noroutes with estimates - use snapped coordinate
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the query options
| fallback_speed | 5 |
| fallback_coordinate | snapped |
Given the node map
"""
a b f h 1
d e g i
"""
And the ways
| nodes |
| abeda |
| fhigf |
When I request a travel distance matrix I should get
| | a | b | f | 1 |
| a | 0 | 300.2 | 900.7 | 1200.9 |
| b | 300.2 | 0 | 600.5 | 900.7 |
| f | 900.7 | 600.5 | 0 | 300.2 |
| 1 | 1200.9 | 900.7 | 300.2 | 0 |
When I request a travel distance matrix I should get
| | a | b | f | 1 |
| a | 0 | 300.2 | 900.7 | 1200.9 |
When I request a travel distance matrix I should get
| | a |
| a | 0 |
| b | 300.2 |
| f | 900.7 |
| 1 | 1200.9 |
Scenario: Ensure consistency with route, and make sure offsets work in both directions
Given a grid size of 100 meters
Given the node map
"""
a b c d e f g h i j
1 2
"""
And the ways
| nodes |
| abcdef |
| fghij |
When I route I should get
| from | to | route | distance |
| 1 | 2 | abcdef,fghij,fghij | 999.9m |
# TODO: this is "correct", but inconsistent with viaroute
When I request a travel distance matrix I should get
| | 1 | 2 |
| 1 | 0 | 1000.7 |
| 2 | 1000.7 | 0 |
-265
View File
@@ -510,268 +510,3 @@ Feature: Basic Duration Matrix
| | a | | | a |
| a | 0 | | a | 0 |
| b | 24.1 | | b | 24.1 |
Scenario: Testbot - Filling in noroutes with estimates (defaults to input coordinate location)
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the query options
| fallback_speed | 5 |
Given the node map
"""
a b f h 1
d e g i
"""
And the ways
| nodes |
| abeda |
| fhigf |
When I request a travel time matrix I should get
| | a | b | f | 1 |
| a | 0 | 30 | 18 | 30 |
| b | 30 | 0 | 12 | 24 |
| f | 18 | 12 | 0 | 30 |
| 1 | 30 | 24 | 30 | 0 |
When I request a travel time matrix I should get
| | a | b | f | 1 |
| a | 0 | 30 | 18 | 30 |
When I request a travel time matrix I should get
| | a |
| a | 0 |
| b | 30 |
| f | 18 |
| 1 | 30 |
When I request a travel time matrix I should get estimates for
| | a | b | f | 1 |
| a | | | Y | Y |
| b | | | Y | Y |
| f | Y | Y | | |
| 1 | Y | Y | | |
When I request a travel time matrix I should get estimates for
| | a | b | f | 1 |
| a | | | Y | Y |
When I request a travel time matrix I should get estimates for
| | a |
| a | |
| b | |
| f | Y |
| 1 | Y |
Scenario: Testbot - Filling in noroutes with estimates - use input coordinate
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the query options
| fallback_speed | 5 |
| fallback_coordinate | input |
Given the node map
"""
a b f h 1
d e g i
"""
And the ways
| nodes |
| abeda |
| fhigf |
When I request a travel time matrix I should get
| | a | b | f | 1 |
| a | 0 | 30 | 18 | 30 |
| b | 30 | 0 | 12 | 24 |
| f | 18 | 12 | 0 | 30 |
| 1 | 30 | 24 | 30 | 0 |
When I request a travel time matrix I should get
| | a | b | f | 1 |
| a | 0 | 30 | 18 | 30 |
When I request a travel time matrix I should get
| | a |
| a | 0 |
| b | 30 |
| f | 18 |
| 1 | 30 |
When I request a travel time matrix I should get estimates for
| | a | b | f | 1 |
| a | | | Y | Y |
| b | | | Y | Y |
| f | Y | Y | | |
| 1 | Y | Y | | |
When I request a travel time matrix I should get estimates for
| | a | b | f | 1 |
| a | | | Y | Y |
When I request a travel time matrix I should get estimates for
| | a |
| a | |
| b | |
| f | Y |
| 1 | Y |
Scenario: Testbot - Filling in noroutes with estimates - use snapped coordinate
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the query options
| fallback_speed | 5 |
| fallback_coordinate | snapped |
Given the node map
"""
a b f h 1
d e g i
"""
And the ways
| nodes |
| abeda |
| fhigf |
When I request a travel time matrix I should get
| | a | b | f | 1 |
| a | 0 | 30 | 18 | 24 |
| b | 30 | 0 | 12 | 18 |
| f | 18 | 12 | 0 | 30 |
| 1 | 24 | 18 | 30 | 0 |
When I request a travel time matrix I should get
| | a | b | f | 1 |
| a | 0 | 30 | 18 | 24 |
When I request a travel time matrix I should get
| | a |
| a | 0 |
| b | 30 |
| f | 18 |
| 1 | 24 |
When I request a travel time matrix I should get estimates for
| | a | b | f | 1 |
| a | | | Y | Y |
| b | | | Y | Y |
| f | Y | Y | | |
| 1 | Y | Y | | |
When I request a travel time matrix I should get estimates for
| | a | b | f | 1 |
| a | | | Y | Y |
When I request a travel time matrix I should get estimates for
| | a |
| a | |
| b | |
| f | Y |
| 1 | Y |
Scenario: Testbot - Travel time matrix of minimal network with scale factor
Given the query options
| scale_factor | 2 |
Given the node map
"""
a b
"""
And the ways
| nodes |
| ab |
When I request a travel time matrix I should get
| | a | b |
| a | 0 | 20 |
| b | 20 | 0 |
Scenario: Testbot - Test fallback speeds and scale factor
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the query options
| scale_factor | 2 |
| fallback_speed | 5 |
| fallback_coordinate | snapped |
Given the node map
"""
a b f h 1
d e g i
"""
And the ways
| nodes |
| abeda |
| fhigf |
When I request a travel time matrix I should get
| | a | b | f | 1 |
| a | 0 | 60 | 36 | 48 |
| b | 60 | 0 | 24 | 36 |
| f | 36 | 24 | 0 | 60 |
| 1 | 48 | 36 | 60 | 0 |
When I request a travel time matrix I should get
| | a | b | f | 1 |
| a | 0 | 60 | 36 | 48 |
When I request a travel time matrix I should get
| | a |
| a | 0 |
| b | 60 |
| f | 36 |
| 1 | 48 |
When I request a travel time matrix I should get estimates for
| | a | b | f | 1 |
| a | | | Y | Y |
| b | | | Y | Y |
| f | Y | Y | | |
| 1 | Y | Y | | |
When I request a travel time matrix I should get estimates for
| | a | b | f | 1 |
| a | | | Y | Y |
When I request a travel time matrix I should get estimates for
| | a |
| a | |
| b | |
| f | Y |
| 1 | Y |
Scenario: Testbot - Travel time matrix of minimal network with overflow scale factor
Given the query options
| scale_factor | 2147483647 |
Given the node map
"""
a b
"""
And the ways
| nodes |
| ab |
When I request a travel time matrix I should get
| | a | b |
| a | 0 | 214748364.6 |
| b | 214748364.6 | 0 |
Scenario: Testbot - Travel time matrix of minimal network with fraction scale factor
Given the query options
| scale_factor | 0.5 |
Given the node map
"""
a b
"""
And the ways
| nodes |
| ab |
When I request a travel time matrix I should get
| | a | b |
| a | 0 | 5 |
| b | 5 | 0 |
+54 -52
View File
@@ -38,15 +38,15 @@ Feature: Multi level routing
Scenario: Testbot - Multi level routing Scenario: Testbot - Multi level routing
Given the node map Given the node map
""" """
ab ef ab ef
\ /
dc hg dc hg
ij mn ij mn
/ \
lkpo lkpo
""" """
And the nodes And the nodes
@@ -67,76 +67,78 @@ Feature: Multi level routing
When I route I should get When I route I should get
| from | to | route | time | | from | to | route | time |
| a | b | abcda,abcda | 25s | | a | b | abcda,abcda | 20s |
| a | f | abcda,cm,mnopm,kp,ijkli,hj,efghe,efghe | 239.2s | | a | f | abcda,cm,mnopm,kp,ijkli,hj,efghe,efghe | 229.4s |
| a | l | abcda,cm,mnopm,kp,ijkli,ijkli | 157.1s | | a | l | abcda,cm,mnopm,kp,ijkli,ijkli | 144.7s |
| a | o | abcda,cm,mnopm,mnopm,mnopm | 137.1s | | a | o | abcda,cm,mnopm,mnopm,mnopm | 124.7s |
| f | l | efghe,hj,ijkli,ijkli | 136.7s | | f | l | efghe,hj,ijkli,ijkli,ijkli | 124.7s |
| f | o | efghe,hj,ijkli,kp,mnopm,mnopm | 162.1s | | f | o | efghe,hj,ijkli,kp,mnopm,mnopm | 144.7s |
| l | o | ijkli,kp,mnopm,mnopm | 80s | | l | o | ijkli,kp,mnopm,mnopm | 60s |
| c | m | cm,cm | 44.7s | | c | m | cm,cm | 44.7s |
| f | a | efghe,hj,ijkli,kp,mnopm,cm,abcda,abcda | 239.2s |
| l | a | ijkli,kp,mnopm,cm,abcda,abcda | 157.1s |
When I request a travel time matrix I should get When I request a travel time matrix I should get
| | a | f | l | o | | | a | f | l | o |
| a | 0 | 239.2 | 157.1 | 137.1 | | a | 0 | 229.4 | 144.7 | 124.7 |
| f | 239.2 | 0 | 136.7 | 162.1 | | f | 229.4 | 0 | 124.7 | 144.7 |
| l | 157.1 | 136.7 | 0 | 80 | | l | 144.7 | 124.7 | 0 | 60 |
| o | 137.1 | 162.1 | 80 | 0 | | o | 124.7 | 144.7 | 60 | 0 |
When I request a travel time matrix I should get When I request a travel time matrix I should get
| | a | f | l | o | | | a | f | l | o |
| a | 0 | 239.2 | 157.1 | 137.1 | | a | 0 | 229.4 | 144.7 | 124.7 |
When I request a travel time matrix I should get When I request a travel time matrix I should get
| | a | | | a |
| a | 0 | | a | 0 |
| f | 239.2 | | f | 229.4 |
| l | 157.1 | | l | 144.7 |
| o | 137.1 | | o | 124.7 |
When I request a travel time matrix I should get When I request a travel time matrix I should get
| | a | f | l | o | | | a | f | l | o |
| a | 0 | 239.2 | 157.1 | 137.1 | | a | 0 | 229.4 | 144.7 | 124.7 |
| o | 137.1 | 162.1 | 80 | 0 | | o | 124.7 | 144.7 | 60 | 0 |
When I request a travel time matrix I should get When I request a travel time matrix I should get
| | a | o | | | a | o |
| a | 0 | 137.1 | | a | 0 | 124.7 |
| f | 239.2 | 162.1 | | f | 229.4 | 144.7 |
| l | 157.1 | 80 | | l | 144.7 | 60 |
| o | 137.1 | 0 | | o | 124.7 | 0 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | f | l | o | | | a | f | l | o |
| a | 0 | 2383.7 | 1566.9 | 1366.8 | | a | 0+-2 | 2287+-2 | 1443+-2 | 1243+-2 |
| f | 2383.7 | 0 | 1293.3 | 1617.3 | | f | 2284+-2 | 0+-2 | 1241+-2 | 1443+-2 |
| l | 1566.9 | 1293.3 | 0 | 800.5 | | l | 1443+-2 | 1244+-2 | 0+-2 | 600+-2 |
| o | 1366.8 | 1617.3 | 800.5 | 0 | | o | 1243+-2 | 1444+-2 | 600+-2 | 0+-2 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | f | l | o | | | a | f | l | o |
| a | 0 | 2383.7 | 1566.9 | 1366.8 | | a | 0 | 2287.2+-2 | 1443+-2 | 1243+-2 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | | | a |
| a | 0 | | a | 0 |
| f | 2383.7 | | f | 2284.5+-2 |
| l | 1566.9 | | l | 1443.1 |
| o | 1366.8 | | o | 1243 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | f | l | o | | | a | f | l | o |
| a | 0 | 2383.7 | 1566.9 | 1366.8 | | a | 0 | 2287+-2 | 1443+-2 | 1243+-2 |
| f | 2383.7 | 0 | 1293.3 | 1617.3 | | o | 1243 | 1444+-2 | 600+-2 | 0+-2 |
When I request a travel distance matrix I should get When I request a travel distance matrix I should get
| | a | o | | | a | o |
| a | 0 | 1366.8 | | a | 0+-2 | 1243+-2 |
| f | 2383.7 | 1617.3 | | f | 2284+-2 | 1443+-2 |
| l | 1566.9 | 800.5 | | l | 1443+-2 | 600+-2 |
| o | 1366.8 | 0 | | o | 1243+-2 | 0+-2 |
Scenario: Testbot - Multi level routing: horizontal road Scenario: Testbot - Multi level routing: horizontal road
Given the node map Given the node map
+1 -1
View File
@@ -182,4 +182,4 @@ Feature: Snap start/end point to the nearest way
| x | m | xe,xe | | x | m | xe,xe |
| x | n | xf,xf | | x | n | xf,xf |
| x | o | xg,xg | | x | o | xg,xg |
| x | p | xh,xh | | x | p | xh,xh |
-36
View File
@@ -1,36 +0,0 @@
@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 |
+2 -5
View File
@@ -12,26 +12,23 @@ namespace contractor
struct ContractorEdgeData struct ContractorEdgeData
{ {
ContractorEdgeData() ContractorEdgeData()
: weight(0), duration(0), distance(0), id(0), originalEdges(0), shortcut(0), forward(0), : weight(0), duration(0), id(0), originalEdges(0), shortcut(0), forward(0), backward(0)
backward(0)
{ {
} }
ContractorEdgeData(EdgeWeight weight, ContractorEdgeData(EdgeWeight weight,
EdgeWeight duration, EdgeWeight duration,
EdgeDistance distance,
unsigned original_edges, unsigned original_edges,
unsigned id, unsigned id,
bool shortcut, bool shortcut,
bool forward, bool forward,
bool backward) bool backward)
: weight(weight), duration(duration), distance(distance), id(id), : weight(weight), duration(duration), id(id),
originalEdges(std::min((1u << 29) - 1u, original_edges)), shortcut(shortcut), originalEdges(std::min((1u << 29) - 1u, original_edges)), shortcut(shortcut),
forward(forward), backward(backward) forward(forward), backward(backward)
{ {
} }
EdgeWeight weight; EdgeWeight weight;
EdgeWeight duration; EdgeWeight duration;
EdgeDistance distance;
unsigned id; unsigned id;
unsigned originalEdges : 29; unsigned originalEdges : 29;
bool shortcut : 1; bool shortcut : 1;
@@ -41,7 +41,6 @@ ContractorGraph toContractorGraph(NodeID number_of_nodes, InputEdgeContainer inp
input_edge.target, input_edge.target,
std::max(input_edge.data.weight, 1), std::max(input_edge.data.weight, 1),
input_edge.data.duration, input_edge.data.duration,
input_edge.data.distance,
1, 1,
input_edge.data.turn_id, input_edge.data.turn_id,
false, false,
@@ -52,7 +51,6 @@ ContractorGraph toContractorGraph(NodeID number_of_nodes, InputEdgeContainer inp
input_edge.source, input_edge.source,
std::max(input_edge.data.weight, 1), std::max(input_edge.data.weight, 1),
input_edge.data.duration, input_edge.data.duration,
input_edge.data.distance,
1, 1,
input_edge.data.turn_id, input_edge.data.turn_id,
false, false,
@@ -84,7 +82,6 @@ ContractorGraph toContractorGraph(NodeID number_of_nodes, InputEdgeContainer inp
forward_edge.data.originalEdges = reverse_edge.data.originalEdges = 1; forward_edge.data.originalEdges = reverse_edge.data.originalEdges = 1;
forward_edge.data.weight = reverse_edge.data.weight = INVALID_EDGE_WEIGHT; forward_edge.data.weight = reverse_edge.data.weight = INVALID_EDGE_WEIGHT;
forward_edge.data.duration = reverse_edge.data.duration = MAXIMAL_EDGE_DURATION; forward_edge.data.duration = reverse_edge.data.duration = MAXIMAL_EDGE_DURATION;
forward_edge.data.distance = reverse_edge.data.distance = MAXIMAL_EDGE_DISTANCE;
// remove parallel edges // remove parallel edges
while (i < edges.size() && edges[i].source == source && edges[i].target == target) while (i < edges.size() && edges[i].source == source && edges[i].target == target)
{ {
@@ -93,16 +90,12 @@ ContractorGraph toContractorGraph(NodeID number_of_nodes, InputEdgeContainer inp
forward_edge.data.weight = std::min(edges[i].data.weight, forward_edge.data.weight); forward_edge.data.weight = std::min(edges[i].data.weight, forward_edge.data.weight);
forward_edge.data.duration = forward_edge.data.duration =
std::min(edges[i].data.duration, forward_edge.data.duration); std::min(edges[i].data.duration, forward_edge.data.duration);
forward_edge.data.distance =
std::min(edges[i].data.distance, forward_edge.data.distance);
} }
if (edges[i].data.backward) if (edges[i].data.backward)
{ {
reverse_edge.data.weight = std::min(edges[i].data.weight, reverse_edge.data.weight); reverse_edge.data.weight = std::min(edges[i].data.weight, reverse_edge.data.weight);
reverse_edge.data.duration = reverse_edge.data.duration =
std::min(edges[i].data.duration, reverse_edge.data.duration); std::min(edges[i].data.duration, reverse_edge.data.duration);
reverse_edge.data.distance =
std::min(edges[i].data.distance, reverse_edge.data.distance);
} }
++i; ++i;
} }
@@ -158,7 +151,6 @@ template <class Edge, typename GraphT> inline std::vector<Edge> toEdges(GraphT g
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.target, "Target id invalid"); BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.target, "Target id invalid");
new_edge.data.weight = data.weight; new_edge.data.weight = data.weight;
new_edge.data.duration = data.duration; new_edge.data.duration = data.duration;
new_edge.data.distance = data.distance;
new_edge.data.shortcut = data.shortcut; new_edge.data.shortcut = data.shortcut;
new_edge.data.turn_id = data.id; new_edge.data.turn_id = data.id;
BOOST_ASSERT_MSG(new_edge.data.turn_id != INT_MAX, // 2^31 BOOST_ASSERT_MSG(new_edge.data.turn_id != INT_MAX, // 2^31
+3 -8
View File
@@ -17,8 +17,7 @@ struct QueryEdge
struct EdgeData struct EdgeData
{ {
explicit EdgeData() explicit EdgeData()
: turn_id(0), shortcut(false), weight(0), duration(0), forward(false), backward(false), : turn_id(0), shortcut(false), weight(0), duration(0), forward(false), backward(false)
distance(0)
{ {
} }
@@ -26,11 +25,10 @@ struct QueryEdge
const bool shortcut, const bool shortcut,
const EdgeWeight weight, const EdgeWeight weight,
const EdgeWeight duration, const EdgeWeight duration,
const EdgeDistance distance,
const bool forward, const bool forward,
const bool backward) const bool backward)
: turn_id(turn_id), shortcut(shortcut), weight(weight), duration(duration), : turn_id(turn_id), shortcut(shortcut), weight(weight), duration(duration),
forward(forward), backward(backward), distance(distance) forward(forward), backward(backward)
{ {
} }
@@ -42,7 +40,6 @@ struct QueryEdge
turn_id = other.id; turn_id = other.id;
forward = other.forward; forward = other.forward;
backward = other.backward; backward = other.backward;
distance = other.distance;
} }
// this ID is either the middle node of the shortcut, or the ID of the edge based node (node // this ID is either the middle node of the shortcut, or the ID of the edge based node (node
// based edge) storing the appropriate data. If `shortcut` is set to true, we get the middle // based edge) storing the appropriate data. If `shortcut` is set to true, we get the middle
@@ -53,7 +50,6 @@ struct QueryEdge
EdgeWeight duration : 30; EdgeWeight duration : 30;
std::uint32_t forward : 1; std::uint32_t forward : 1;
std::uint32_t backward : 1; std::uint32_t backward : 1;
EdgeDistance distance;
} data; } data;
QueryEdge() : source(SPECIAL_NODEID), target(SPECIAL_NODEID) {} QueryEdge() : source(SPECIAL_NODEID), target(SPECIAL_NODEID) {}
@@ -73,8 +69,7 @@ struct QueryEdge
return (source == right.source && target == right.target && return (source == right.source && target == right.target &&
data.weight == right.data.weight && data.duration == right.data.duration && data.weight == right.data.weight && data.duration == right.data.duration &&
data.shortcut == right.data.shortcut && data.forward == right.data.forward && data.shortcut == right.data.shortcut && data.forward == right.data.forward &&
data.backward == right.data.backward && data.turn_id == right.data.turn_id && data.backward == right.data.backward && data.turn_id == right.data.turn_id);
data.distance == right.data.distance);
} }
}; };
} }
+11 -37
View File
@@ -22,7 +22,6 @@ class CellCustomizer
{ {
bool from_clique; bool from_clique;
EdgeDuration duration; EdgeDuration duration;
EdgeDistance distance;
}; };
public: public:
@@ -61,7 +60,7 @@ class CellCustomizer
} }
} }
heap.Clear(); heap.Clear();
heap.Insert(source, 0, {false, 0, 0}); heap.Insert(source, 0, {false, 0});
// explore search space // explore search space
while (!heap.Empty() && !destinations_set.empty()) while (!heap.Empty() && !destinations_set.empty())
@@ -69,18 +68,8 @@ class CellCustomizer
const NodeID node = heap.DeleteMin(); const NodeID node = heap.DeleteMin();
const EdgeWeight weight = heap.GetKey(node); const EdgeWeight weight = heap.GetKey(node);
const EdgeDuration duration = heap.GetData(node).duration; const EdgeDuration duration = heap.GetData(node).duration;
const EdgeDistance distance = heap.GetData(node).distance;
RelaxNode(graph, RelaxNode(graph, cells, allowed_nodes, metric, heap, level, node, weight, duration);
cells,
allowed_nodes,
metric,
heap,
level,
node,
weight,
duration,
distance);
destinations_set.erase(node); destinations_set.erase(node);
} }
@@ -88,27 +77,21 @@ class CellCustomizer
// fill a map of destination nodes to placeholder pointers // fill a map of destination nodes to placeholder pointers
auto weights = cell.GetOutWeight(source); auto weights = cell.GetOutWeight(source);
auto durations = cell.GetOutDuration(source); auto durations = cell.GetOutDuration(source);
auto distances = cell.GetOutDistance(source);
for (auto &destination : destinations) for (auto &destination : destinations)
{ {
BOOST_ASSERT(!weights.empty()); BOOST_ASSERT(!weights.empty());
BOOST_ASSERT(!durations.empty()); BOOST_ASSERT(!durations.empty());
BOOST_ASSERT(!distances.empty());
const bool inserted = heap.WasInserted(destination); const bool inserted = heap.WasInserted(destination);
weights.front() = inserted ? heap.GetKey(destination) : INVALID_EDGE_WEIGHT; weights.front() = inserted ? heap.GetKey(destination) : INVALID_EDGE_WEIGHT;
durations.front() = durations.front() =
inserted ? heap.GetData(destination).duration : MAXIMAL_EDGE_DURATION; inserted ? heap.GetData(destination).duration : MAXIMAL_EDGE_DURATION;
distances.front() =
inserted ? heap.GetData(destination).distance : INVALID_EDGE_DISTANCE;
weights.advance_begin(1); weights.advance_begin(1);
durations.advance_begin(1); durations.advance_begin(1);
distances.advance_begin(1);
} }
BOOST_ASSERT(weights.empty()); BOOST_ASSERT(weights.empty());
BOOST_ASSERT(durations.empty()); BOOST_ASSERT(durations.empty());
BOOST_ASSERT(distances.empty());
} }
} }
@@ -145,8 +128,7 @@ class CellCustomizer
LevelID level, LevelID level,
NodeID node, NodeID node,
EdgeWeight weight, EdgeWeight weight,
EdgeDuration duration, EdgeDuration duration) const
EdgeDistance distance) const
{ {
auto first_level = level == 1; auto first_level = level == 1;
BOOST_ASSERT(heap.WasInserted(node)); BOOST_ASSERT(heap.WasInserted(node));
@@ -167,7 +149,6 @@ class CellCustomizer
auto subcell = cells.GetCell(metric, level - 1, subcell_id); auto subcell = cells.GetCell(metric, level - 1, subcell_id);
auto subcell_destination = subcell.GetDestinationNodes().begin(); auto subcell_destination = subcell.GetDestinationNodes().begin();
auto subcell_duration = subcell.GetOutDuration(node).begin(); auto subcell_duration = subcell.GetOutDuration(node).begin();
auto subcell_distance = subcell.GetOutDistance(node).begin();
for (auto subcell_weight : subcell.GetOutWeight(node)) for (auto subcell_weight : subcell.GetOutWeight(node))
{ {
if (subcell_weight != INVALID_EDGE_WEIGHT) if (subcell_weight != INVALID_EDGE_WEIGHT)
@@ -180,24 +161,20 @@ class CellCustomizer
const EdgeWeight to_weight = weight + subcell_weight; const EdgeWeight to_weight = weight + subcell_weight;
const EdgeDuration to_duration = duration + *subcell_duration; const EdgeDuration to_duration = duration + *subcell_duration;
const EdgeDistance to_distance = distance + *subcell_distance;
if (!heap.WasInserted(to)) if (!heap.WasInserted(to))
{ {
heap.Insert(to, to_weight, {true, to_duration, to_distance}); heap.Insert(to, to_weight, {true, to_duration});
} }
else if (std::tie(to_weight, to_duration, to_distance) < else if (std::tie(to_weight, to_duration) <
std::tie(heap.GetKey(to), std::tie(heap.GetKey(to), heap.GetData(to).duration))
heap.GetData(to).duration,
heap.GetData(to).distance))
{ {
heap.DecreaseKey(to, to_weight); heap.DecreaseKey(to, to_weight);
heap.GetData(to) = {true, to_duration, to_distance}; heap.GetData(to) = {true, to_duration};
} }
} }
++subcell_destination; ++subcell_destination;
++subcell_duration; ++subcell_duration;
++subcell_distance;
} }
} }
} }
@@ -218,18 +195,15 @@ class CellCustomizer
{ {
const EdgeWeight to_weight = weight + data.weight; const EdgeWeight to_weight = weight + data.weight;
const EdgeDuration to_duration = duration + data.duration; const EdgeDuration to_duration = duration + data.duration;
const EdgeDistance to_distance = distance + data.distance;
if (!heap.WasInserted(to)) if (!heap.WasInserted(to))
{ {
heap.Insert( heap.Insert(to, to_weight, {false, duration + data.duration});
to, to_weight, {false, duration + data.duration, distance + data.distance});
} }
else if (std::tie(to_weight, to_duration, to_distance) < else if (std::tie(to_weight, to_duration) <
std::tie( std::tie(heap.GetKey(to), heap.GetData(to).duration))
heap.GetKey(to), heap.GetData(to).duration, heap.GetData(to).distance))
{ {
heap.DecreaseKey(to, to_weight); heap.DecreaseKey(to, to_weight);
heap.GetData(to) = {false, to_duration, to_distance}; heap.GetData(to) = {false, to_duration};
} }
} }
} }
-1
View File
@@ -20,7 +20,6 @@ template <storage::Ownership Ownership> struct CellMetricImpl
Vector<EdgeWeight> weights; Vector<EdgeWeight> weights;
Vector<EdgeDuration> durations; Vector<EdgeDuration> durations;
Vector<EdgeDistance> distances;
}; };
} }
+3 -10
View File
@@ -58,10 +58,8 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
MultiLevelGraph(PartitionerGraphT &&graph, MultiLevelGraph(PartitionerGraphT &&graph,
Vector<EdgeWeight> node_weights_, Vector<EdgeWeight> node_weights_,
Vector<EdgeDuration> node_durations_, Vector<EdgeDuration> node_durations_)
Vector<EdgeDistance> node_distances_) : node_weights(std::move(node_weights_)), node_durations(std::move(node_durations_))
: node_weights(std::move(node_weights_)), node_durations(std::move(node_durations_)),
node_distances(std::move(node_distances_))
{ {
util::ViewOrVector<PartitionerGraphT::EdgeArrayEntry, storage::Ownership::Container> util::ViewOrVector<PartitionerGraphT::EdgeArrayEntry, storage::Ownership::Container>
original_edge_array; original_edge_array;
@@ -85,13 +83,11 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
Vector<EdgeOffset> node_to_edge_offset_, Vector<EdgeOffset> node_to_edge_offset_,
Vector<EdgeWeight> node_weights_, Vector<EdgeWeight> node_weights_,
Vector<EdgeDuration> node_durations_, Vector<EdgeDuration> node_durations_,
Vector<EdgeDistance> node_distances_,
Vector<bool> is_forward_edge_, Vector<bool> is_forward_edge_,
Vector<bool> is_backward_edge_) Vector<bool> is_backward_edge_)
: SuperT(std::move(node_array_), std::move(edge_array_), std::move(node_to_edge_offset_)), : SuperT(std::move(node_array_), std::move(edge_array_), std::move(node_to_edge_offset_)),
node_weights(std::move(node_weights_)), node_durations(std::move(node_durations_)), node_weights(std::move(node_weights_)), node_durations(std::move(node_durations_)),
node_distances(std::move(node_distances_)), is_forward_edge(is_forward_edge_), is_forward_edge(is_forward_edge_), is_backward_edge(is_backward_edge_)
is_backward_edge(is_backward_edge_)
{ {
} }
@@ -99,8 +95,6 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
EdgeWeight GetNodeDuration(NodeID node) const { return node_durations[node]; } EdgeWeight GetNodeDuration(NodeID node) const { return node_durations[node]; }
EdgeDistance GetNodeDistance(NodeID node) const { return node_distances[node]; }
bool IsForwardEdge(EdgeID edge) const { return is_forward_edge[edge]; } bool IsForwardEdge(EdgeID edge) const { return is_forward_edge[edge]; }
bool IsBackwardEdge(EdgeID edge) const { return is_backward_edge[edge]; } bool IsBackwardEdge(EdgeID edge) const { return is_backward_edge[edge]; }
@@ -117,7 +111,6 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
protected: protected:
Vector<EdgeWeight> node_weights; Vector<EdgeWeight> node_weights;
Vector<EdgeDuration> node_durations; Vector<EdgeDuration> node_durations;
Vector<EdgeDistance> node_distances;
Vector<bool> is_forward_edge; Vector<bool> is_forward_edge;
Vector<bool> is_backward_edge; Vector<bool> is_backward_edge;
}; };
-4
View File
@@ -23,7 +23,6 @@ inline void read(storage::tar::FileReader &reader,
{ {
storage::serialization::read(reader, name + "/weights", metric.weights); storage::serialization::read(reader, name + "/weights", metric.weights);
storage::serialization::read(reader, name + "/durations", metric.durations); storage::serialization::read(reader, name + "/durations", metric.durations);
storage::serialization::read(reader, name + "/distances", metric.distances);
} }
template <storage::Ownership Ownership> template <storage::Ownership Ownership>
@@ -33,7 +32,6 @@ inline void write(storage::tar::FileWriter &writer,
{ {
storage::serialization::write(writer, name + "/weights", metric.weights); storage::serialization::write(writer, name + "/weights", metric.weights);
storage::serialization::write(writer, name + "/durations", metric.durations); storage::serialization::write(writer, name + "/durations", metric.durations);
storage::serialization::write(writer, name + "/distances", metric.distances);
} }
template <typename EdgeDataT, storage::Ownership Ownership> template <typename EdgeDataT, storage::Ownership Ownership>
@@ -44,7 +42,6 @@ inline void read(storage::tar::FileReader &reader,
storage::serialization::read(reader, name + "/node_array", graph.node_array); storage::serialization::read(reader, name + "/node_array", graph.node_array);
storage::serialization::read(reader, name + "/node_weights", graph.node_weights); storage::serialization::read(reader, name + "/node_weights", graph.node_weights);
storage::serialization::read(reader, name + "/node_durations", graph.node_durations); storage::serialization::read(reader, name + "/node_durations", graph.node_durations);
storage::serialization::read(reader, name + "/node_distances", graph.node_distances);
storage::serialization::read(reader, name + "/edge_array", graph.edge_array); storage::serialization::read(reader, name + "/edge_array", graph.edge_array);
storage::serialization::read(reader, name + "/is_forward_edge", graph.is_forward_edge); storage::serialization::read(reader, name + "/is_forward_edge", graph.is_forward_edge);
storage::serialization::read(reader, name + "/is_backward_edge", graph.is_backward_edge); storage::serialization::read(reader, name + "/is_backward_edge", graph.is_backward_edge);
@@ -59,7 +56,6 @@ inline void write(storage::tar::FileWriter &writer,
storage::serialization::write(writer, name + "/node_array", graph.node_array); storage::serialization::write(writer, name + "/node_array", graph.node_array);
storage::serialization::write(writer, name + "/node_weights", graph.node_weights); storage::serialization::write(writer, name + "/node_weights", graph.node_weights);
storage::serialization::write(writer, name + "/node_durations", graph.node_durations); storage::serialization::write(writer, name + "/node_durations", graph.node_durations);
storage::serialization::write(writer, name + "/node_distances", graph.node_distances);
storage::serialization::write(writer, name + "/edge_array", graph.edge_array); storage::serialization::write(writer, name + "/edge_array", graph.edge_array);
storage::serialization::write(writer, name + "/is_forward_edge", graph.is_forward_edge); storage::serialization::write(writer, name + "/is_forward_edge", graph.is_forward_edge);
storage::serialization::write(writer, name + "/is_backward_edge", graph.is_backward_edge); storage::serialization::write(writer, name + "/is_backward_edge", graph.is_backward_edge);
-5
View File
@@ -6,7 +6,6 @@
#include "engine/api/json_factory.hpp" #include "engine/api/json_factory.hpp"
#include "engine/hint.hpp" #include "engine/hint.hpp"
#include "util/coordinate_calculation.hpp"
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/range/algorithm/transform.hpp> #include <boost/range/algorithm/transform.hpp>
@@ -54,8 +53,6 @@ class BaseAPI
// TODO: check forward/reverse // TODO: check forward/reverse
return json::makeWaypoint( return json::makeWaypoint(
phantom.location, phantom.location,
util::coordinate_calculation::fccApproximateDistance(phantom.location,
phantom.input_location),
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string(), facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string(),
Hint{phantom, facade.GetCheckSum()}); Hint{phantom, facade.GetCheckSum()});
} }
@@ -64,8 +61,6 @@ class BaseAPI
// TODO: check forward/reverse // TODO: check forward/reverse
return json::makeWaypoint( return json::makeWaypoint(
phantom.location, phantom.location,
util::coordinate_calculation::fccApproximateDistance(phantom.location,
phantom.input_location),
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)) facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
.to_string()); .to_string());
} }
+2 -22
View File
@@ -63,13 +63,6 @@ namespace api
*/ */
struct BaseParameters struct BaseParameters
{ {
enum class SnappingType
{
Default,
Any
};
std::vector<util::Coordinate> coordinates; std::vector<util::Coordinate> coordinates;
std::vector<boost::optional<Hint>> hints; std::vector<boost::optional<Hint>> hints;
std::vector<boost::optional<double>> radiuses; std::vector<boost::optional<double>> radiuses;
@@ -80,34 +73,21 @@ struct BaseParameters
// Adds hints to response which can be included in subsequent requests, see `hints` above. // Adds hints to response which can be included in subsequent requests, see `hints` above.
bool generate_hints = true; bool generate_hints = true;
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_ = {},
std::vector<boost::optional<double>> radiuses_ = {}, std::vector<boost::optional<double>> radiuses_ = {},
std::vector<boost::optional<Bearing>> bearings_ = {}, std::vector<boost::optional<Bearing>> bearings_ = {},
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,
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_), 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()) &&
+4 -7
View File
@@ -33,7 +33,7 @@ namespace json
namespace detail namespace detail
{ {
util::json::Array coordinateToLonLat(const util::Coordinate &coordinate); util::json::Array coordinateToLonLat(const util::Coordinate coordinate);
/** /**
* Ensures that a bearing value is a whole number, and clamped to the range 0-359 * Ensures that a bearing value is a whole number, and clamped to the range 0-359
@@ -86,14 +86,11 @@ util::json::Object makeRoute(const guidance::Route &route,
const char *weight_name); const char *weight_name);
// Creates a Waypoint without Hint, see the Hint overload below // Creates a Waypoint without Hint, see the Hint overload below
util::json::Object util::json::Object makeWaypoint(const util::Coordinate location, std::string name);
makeWaypoint(const util::Coordinate &location, const double &distance, std::string name);
// Creates a Waypoint with Hint, see the overload above when Hint is not needed // Creates a Waypoint with Hint, see the overload above when Hint is not needed
util::json::Object makeWaypoint(const util::Coordinate &location, util::json::Object
const double &distance, makeWaypoint(const util::Coordinate location, std::string name, const Hint &hint);
std::string name,
const Hint &hint);
util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps); util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps);
+1
View File
@@ -41,6 +41,7 @@ class NearestAPI final : public BaseAPI
[this](const PhantomNodeWithDistance &phantom_with_distance) { [this](const PhantomNodeWithDistance &phantom_with_distance) {
auto &phantom_node = phantom_with_distance.phantom_node; auto &phantom_node = phantom_with_distance.phantom_node;
auto waypoint = MakeWaypoint(phantom_node); auto waypoint = MakeWaypoint(phantom_node);
waypoint.values["distance"] = phantom_with_distance.distance;
util::json::Array nodes; util::json::Array nodes;
-29
View File
@@ -31,15 +31,6 @@ namespace api
class TableAPI final : public BaseAPI class TableAPI final : public BaseAPI
{ {
public: public:
struct TableCellRef
{
TableCellRef(const std::size_t &row, const std::size_t &column) : row{row}, column{column}
{
}
std::size_t row;
std::size_t column;
};
TableAPI(const datafacade::BaseDataFacade &facade_, const TableParameters &parameters_) TableAPI(const datafacade::BaseDataFacade &facade_, const TableParameters &parameters_)
: BaseAPI(facade_, parameters_), parameters(parameters_) : BaseAPI(facade_, parameters_), parameters(parameters_)
{ {
@@ -48,7 +39,6 @@ class TableAPI final : public BaseAPI
virtual void virtual void
MakeResponse(const std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>> &tables, MakeResponse(const std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>> &tables,
const std::vector<PhantomNode> &phantoms, const std::vector<PhantomNode> &phantoms,
const std::vector<TableCellRef> &fallback_speed_cells,
util::json::Object &response) const util::json::Object &response) const
{ {
auto number_of_sources = parameters.sources.size(); auto number_of_sources = parameters.sources.size();
@@ -87,11 +77,6 @@ class TableAPI final : public BaseAPI
MakeDistanceTable(tables.second, number_of_sources, number_of_destinations); MakeDistanceTable(tables.second, number_of_sources, number_of_destinations);
} }
if (parameters.fallback_speed != INVALID_FALLBACK_SPEED && parameters.fallback_speed > 0)
{
response.values["fallback_speed_cells"] = MakeEstimatesTable(fallback_speed_cells);
}
response.values["code"] = "Ok"; response.values["code"] = "Ok";
} }
@@ -178,20 +163,6 @@ class TableAPI final : public BaseAPI
return json_table; return json_table;
} }
virtual util::json::Array
MakeEstimatesTable(const std::vector<TableCellRef> &fallback_speed_cells) const
{
util::json::Array json_table;
std::for_each(
fallback_speed_cells.begin(), fallback_speed_cells.end(), [&](const auto &cell) {
util::json::Array row;
row.values.push_back(util::json::Number(cell.row));
row.values.push_back(util::json::Number(cell.column));
json_table.values.push_back(std::move(row));
});
return json_table;
}
const TableParameters &parameters; const TableParameters &parameters;
}; };
+11 -35
View File
@@ -59,15 +59,6 @@ struct TableParameters : public BaseParameters
{ {
std::vector<std::size_t> sources; std::vector<std::size_t> sources;
std::vector<std::size_t> destinations; std::vector<std::size_t> destinations;
double fallback_speed = INVALID_FALLBACK_SPEED;
enum class FallbackCoordinateType
{
Input = 0,
Snapped = 1
};
FallbackCoordinateType fallback_coordinate_type = FallbackCoordinateType::Input;
enum class AnnotationsType enum class AnnotationsType
{ {
@@ -78,7 +69,6 @@ struct TableParameters : public BaseParameters
}; };
AnnotationsType annotations = AnnotationsType::Duration; AnnotationsType annotations = AnnotationsType::Duration;
double scale_factor = 1;
TableParameters() = default; TableParameters() = default;
template <typename... Args> template <typename... Args>
@@ -100,21 +90,6 @@ struct TableParameters : public BaseParameters
{ {
} }
template <typename... Args>
TableParameters(std::vector<std::size_t> sources_,
std::vector<std::size_t> destinations_,
const AnnotationsType annotations_,
double fallback_speed_,
FallbackCoordinateType fallback_coordinate_type_,
double scale_factor_,
Args... args_)
: BaseParameters{std::forward<Args>(args_)...}, sources{std::move(sources_)},
destinations{std::move(destinations_)}, fallback_speed{fallback_speed_},
fallback_coordinate_type{fallback_coordinate_type_}, annotations{annotations_},
scale_factor{scale_factor_}
{
}
bool IsValid() const bool IsValid() const
{ {
if (!BaseParameters::IsValid()) if (!BaseParameters::IsValid())
@@ -126,7 +101,14 @@ struct TableParameters : public BaseParameters
// 1/ The user is able to specify duplicates in srcs and dsts, in that case it's their fault // 1/ The user is able to specify duplicates in srcs and dsts, in that case it's their fault
// 2/ 0 <= index < len(locations) // 2/ len(srcs) and len(dsts) smaller or equal to len(locations)
if (sources.size() > coordinates.size())
return false;
if (destinations.size() > coordinates.size())
return false;
// 3/ 0 <= index < len(locations)
const auto not_in_range = [this](const std::size_t x) { return x >= coordinates.size(); }; const auto not_in_range = [this](const std::size_t x) { return x >= coordinates.size(); };
if (std::any_of(begin(sources), end(sources), not_in_range)) if (std::any_of(begin(sources), end(sources), not_in_range))
@@ -135,12 +117,6 @@ struct TableParameters : public BaseParameters
if (std::any_of(begin(destinations), end(destinations), not_in_range)) if (std::any_of(begin(destinations), end(destinations), not_in_range))
return false; return false;
if (fallback_speed <= 0)
return false;
if (scale_factor <= 0)
return false;
return true; return true;
} }
}; };
@@ -164,8 +140,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
@@ -78,8 +78,6 @@ template <> class AlgorithmDataFacade<MLD>
virtual EdgeWeight GetNodeDuration(const NodeID node) const = 0; // TODO: to be removed virtual EdgeWeight GetNodeDuration(const NodeID node) const = 0; // TODO: to be removed
virtual EdgeDistance GetNodeDistance(const NodeID node) const = 0;
virtual bool IsForwardEdge(EdgeID edge) const = 0; virtual bool IsForwardEdge(EdgeID edge) const = 0;
virtual bool IsBackwardEdge(EdgeID edge) const = 0; virtual bool IsBackwardEdge(EdgeID edge) const = 0;
@@ -312,13 +312,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
std::vector<PhantomNodeWithDistance> std::vector<PhantomNodeWithDistance>
NearestPhantomNodesInRange(const util::Coordinate input_coordinate, NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const float max_distance, const float max_distance,
const Approach approach, const Approach approach) const override final
const bool use_all_edges) const override final
{ {
BOOST_ASSERT(m_geospatial_query.get()); BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodesInRange( return m_geospatial_query->NearestPhantomNodesInRange(
input_coordinate, max_distance, approach, use_all_edges); input_coordinate, max_distance, approach);
} }
std::vector<PhantomNodeWithDistance> std::vector<PhantomNodeWithDistance>
@@ -326,13 +325,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
const float max_distance, const float max_distance,
const int bearing, const int bearing,
const int bearing_range, const int bearing_range,
const Approach approach, const Approach approach) const override final
const bool use_all_edges) const override final
{ {
BOOST_ASSERT(m_geospatial_query.get()); BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodesInRange( return m_geospatial_query->NearestPhantomNodesInRange(
input_coordinate, max_distance, bearing, bearing_range, approach, use_all_edges); input_coordinate, max_distance, bearing, bearing_range, approach);
} }
std::vector<PhantomNodeWithDistance> std::vector<PhantomNodeWithDistance>
@@ -384,84 +382,50 @@ 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> NearestPhantomNodeWithAlternativeFromBigComponent( std::pair<PhantomNode, PhantomNode>
const util::Coordinate input_coordinate, NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const Approach approach, const Approach approach) 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, input_coordinate, approach);
approach,
use_all_edges,
minimum_stoppage_penalty,
maximum_stoppage_penalty);
} }
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent( std::pair<PhantomNode, PhantomNode>
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 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, input_coordinate, max_distance, approach);
max_distance,
approach,
use_all_edges,
minimum_stoppage_penalty,
maximum_stoppage_penalty);
} }
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent( std::pair<PhantomNode, PhantomNode>
const util::Coordinate input_coordinate, NearestPhantomNodeWithAlternativeFromBigComponent(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 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, input_coordinate, max_distance, bearing, bearing_range, approach);
max_distance,
bearing,
bearing_range,
approach,
use_all_edges,
minimum_stoppage_penalty,
maximum_stoppage_penalty);
} }
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent( std::pair<PhantomNode, PhantomNode>
const util::Coordinate input_coordinate, NearestPhantomNodeWithAlternativeFromBigComponent(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 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, input_coordinate, bearing, bearing_range, approach);
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; }
@@ -733,11 +697,6 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
return query_graph.GetNodeDuration(node); return query_graph.GetNodeDuration(node);
} }
EdgeDistance GetNodeDistance(const NodeID node) const override final
{
return query_graph.GetNodeDistance(node);
}
bool IsForwardEdge(const NodeID node) const override final bool IsForwardEdge(const NodeID node) const override final
{ {
return query_graph.IsForwardEdge(node); return query_graph.IsForwardEdge(node);
+20 -34
View File
@@ -126,13 +126,11 @@ class BaseDataFacade
const float max_distance, const float max_distance,
const int bearing, const int bearing,
const int bearing_range, const int bearing_range,
const Approach approach, const Approach approach) const = 0;
const bool use_all_edges) const = 0;
virtual std::vector<PhantomNodeWithDistance> virtual std::vector<PhantomNodeWithDistance>
NearestPhantomNodesInRange(const util::Coordinate input_coordinate, NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const float max_distance, const float max_distance,
const Approach approach, const Approach approach) const = 0;
const bool use_all_edges) const = 0;
virtual std::vector<PhantomNodeWithDistance> virtual std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate, NearestPhantomNodes(const util::Coordinate input_coordinate,
@@ -157,36 +155,24 @@ 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> NearestPhantomNodeWithAlternativeFromBigComponent( virtual std::pair<PhantomNode, PhantomNode>
const util::Coordinate input_coordinate, NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const Approach approach, const Approach approach) 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 = 0;
const util::Coordinate input_coordinate, virtual std::pair<PhantomNode, PhantomNode>
const double max_distance, NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const Approach approach, const double max_distance,
const bool use_all_edges, const int bearing,
const double minimum_stoppage_penalty, const int bearing_range,
const double maximum_stoppage_penalty) const = 0; const Approach approach) const = 0;
virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent( virtual std::pair<PhantomNode, PhantomNode>
const util::Coordinate input_coordinate, NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance, const int bearing,
const int bearing, const int bearing_range,
const int bearing_range, const Approach approach) const = 0;
const Approach approach,
const bool use_all_edges,
const double minimum_stoppage_penalty,
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;
@@ -10,7 +10,6 @@
#include <boost/iostreams/device/mapped_file.hpp> #include <boost/iostreams/device/mapped_file.hpp>
#include <memory> #include <memory>
#include <string>
namespace osrm namespace osrm
{ {
@@ -25,7 +24,8 @@ namespace datafacade
class MMapMemoryAllocator : public ContiguousBlockAllocator class MMapMemoryAllocator : public ContiguousBlockAllocator
{ {
public: public:
explicit MMapMemoryAllocator(const storage::StorageConfig &config); explicit MMapMemoryAllocator(const storage::StorageConfig &config,
const boost::filesystem::path &memory_file);
~MMapMemoryAllocator() override final; ~MMapMemoryAllocator() override final;
// interface to give access to the datafacades // interface to give access to the datafacades
@@ -33,8 +33,8 @@ class MMapMemoryAllocator : public ContiguousBlockAllocator
private: private:
storage::SharedDataIndex index; storage::SharedDataIndex index;
std::vector<boost::iostreams::mapped_file> mapped_memory_files; util::vector_view<char> mapped_memory;
std::string rtree_filename; boost::iostreams::mapped_file mapped_memory_file;
}; };
} // namespace datafacade } // namespace datafacade
+3 -2
View File
@@ -32,8 +32,9 @@ class ExternalProvider final : public DataFacadeProvider<AlgorithmT, FacadeT>
public: public:
using Facade = typename DataFacadeProvider<AlgorithmT, FacadeT>::Facade; using Facade = typename DataFacadeProvider<AlgorithmT, FacadeT>::Facade;
ExternalProvider(const storage::StorageConfig &config) ExternalProvider(const storage::StorageConfig &config,
: facade_factory(std::make_shared<datafacade::MMapMemoryAllocator>(config)) const boost::filesystem::path &memory_file)
: facade_factory(std::make_shared<datafacade::MMapMemoryAllocator>(config, memory_file))
{ {
} }
+5 -9
View File
@@ -63,16 +63,12 @@ template <typename Algorithm> class Engine final : public EngineInterface
<< "\" with algorithm " << routing_algorithms::name<Algorithm>(); << "\" with algorithm " << routing_algorithms::name<Algorithm>();
facade_provider = std::make_unique<WatchingProvider<Algorithm>>(config.dataset_name); facade_provider = std::make_unique<WatchingProvider<Algorithm>>(config.dataset_name);
} }
else if (!config.memory_file.empty() || config.use_mmap) else if (!config.memory_file.empty())
{ {
if (!config.memory_file.empty()) util::Log(logDEBUG) << "Using memory mapped filed at " << config.memory_file
{ << " with algorithm " << routing_algorithms::name<Algorithm>();
util::Log(logWARNING) facade_provider = std::make_unique<ExternalProvider<Algorithm>>(config.storage_config,
<< "The 'memory_file' option is DEPRECATED - using direct mmaping instead"; config.memory_file);
}
util::Log(logDEBUG) << "Using direct memory mapping with algorithm "
<< routing_algorithms::name<Algorithm>();
facade_provider = std::make_unique<ExternalProvider<Algorithm>>(config.storage_config);
} }
else else
{ {
-1
View File
@@ -89,7 +89,6 @@ struct EngineConfig final
int max_alternatives = 3; // set an arbitrary upper bound; can be adjusted by user int max_alternatives = 3; // set an arbitrary upper bound; can be adjusted by user
bool use_shared_memory = true; bool use_shared_memory = true;
boost::filesystem::path memory_file; boost::filesystem::path memory_file;
bool use_mmap = true;
Algorithm algorithm = Algorithm::CH; Algorithm algorithm = Algorithm::CH;
std::string verbosity; std::string verbosity;
std::string dataset_name; std::string dataset_name;
+51 -153
View File
@@ -53,15 +53,13 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
std::vector<PhantomNodeWithDistance> std::vector<PhantomNodeWithDistance>
NearestPhantomNodesInRange(const util::Coordinate input_coordinate, NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const double max_distance, const double max_distance,
const Approach approach, const Approach approach) const
const bool use_all_edges) const
{ {
auto results = rtree.Nearest( auto results = rtree.Nearest(
input_coordinate, input_coordinate,
[this, approach, &input_coordinate, use_all_edges](const CandidateSegment &segment) { [this, approach, &input_coordinate](const CandidateSegment &segment) {
return boolPairAnd( return boolPairAnd(boolPairAnd(HasValidEdge(segment), CheckSegmentExclude(segment)),
boolPairAnd(HasValidEdge(segment, use_all_edges), CheckSegmentExclude(segment)), CheckApproach(input_coordinate, segment, approach));
CheckApproach(input_coordinate, segment, approach));
}, },
[this, max_distance, input_coordinate](const std::size_t, [this, max_distance, input_coordinate](const std::size_t,
const CandidateSegment &segment) { const CandidateSegment &segment) {
@@ -78,17 +76,15 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
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
const bool use_all_edges) const
{ {
auto results = rtree.Nearest( auto results = rtree.Nearest(
input_coordinate, input_coordinate,
[this, approach, &input_coordinate, bearing, bearing_range, use_all_edges]( [this, approach, &input_coordinate, bearing, bearing_range](
const CandidateSegment &segment) { const CandidateSegment &segment) {
auto use_direction = auto use_direction =
boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range), boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range),
boolPairAnd(HasValidEdge(segment, use_all_edges), boolPairAnd(HasValidEdge(segment), CheckSegmentExclude(segment)));
CheckSegmentExclude(segment)));
use_direction = use_direction =
boolPairAnd(use_direction, CheckApproach(input_coordinate, segment, approach)); boolPairAnd(use_direction, CheckApproach(input_coordinate, segment, approach));
return use_direction; return use_direction;
@@ -205,25 +201,18 @@ 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 double max_distance, const double max_distance,
const Approach approach, const Approach approach) 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;
auto results = rtree.Nearest( auto results = rtree.Nearest(
input_coordinate, input_coordinate,
[this, [this, approach, &input_coordinate, &has_big_component, &has_small_component](
approach, const CandidateSegment &segment) {
&input_coordinate,
&has_big_component,
&has_small_component,
&use_all_edges](const CandidateSegment &segment) {
auto use_segment = auto use_segment =
(!has_small_component || (!has_big_component && !IsTinyComponent(segment))); (!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
auto use_directions = std::make_pair(use_segment, use_segment); auto use_directions = std::make_pair(use_segment, use_segment);
const auto valid_edges = HasValidEdge(segment, use_all_edges); const auto valid_edges = HasValidEdge(segment);
const auto admissible_segments = CheckSegmentExclude(segment); const auto admissible_segments = CheckSegmentExclude(segment);
use_directions = boolPairAnd(use_directions, admissible_segments); use_directions = boolPairAnd(use_directions, admissible_segments);
use_directions = boolPairAnd(use_directions, valid_edges); use_directions = boolPairAnd(use_directions, valid_edges);
@@ -250,39 +239,27 @@ 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( return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node,
MakePhantomNode( MakePhantomNode(input_coordinate, results.back()).phantom_node);
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
// a second phantom node is return that is the nearest coordinate in a big component. // a second phantom node is return that is the nearest coordinate in a big component.
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
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;
auto results = rtree.Nearest( auto results = rtree.Nearest(
input_coordinate, input_coordinate,
[this, [this, approach, &input_coordinate, &has_big_component, &has_small_component](
approach, const CandidateSegment &segment) {
&input_coordinate,
&has_big_component,
&has_small_component,
&use_all_edges](const CandidateSegment &segment) {
auto use_segment = auto use_segment =
(!has_small_component || (!has_big_component && !IsTinyComponent(segment))); (!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
auto use_directions = std::make_pair(use_segment, use_segment); auto use_directions = std::make_pair(use_segment, use_segment);
const auto valid_edges = HasValidEdge(segment, use_all_edges); const auto valid_edges = HasValidEdge(segment);
const auto admissible_segments = CheckSegmentExclude(segment); const auto admissible_segments = CheckSegmentExclude(segment);
use_directions = boolPairAnd(use_directions, admissible_segments); use_directions = boolPairAnd(use_directions, admissible_segments);
use_directions = boolPairAnd(use_directions, valid_edges); use_directions = boolPairAnd(use_directions, valid_edges);
@@ -307,13 +284,8 @@ 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( return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node,
MakePhantomNode( MakePhantomNode(input_coordinate, results.back()).phantom_node);
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
@@ -322,10 +294,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, NearestPhantomNodeWithAlternativeFromBigComponent(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
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;
@@ -337,13 +306,12 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
bearing, bearing,
bearing_range, bearing_range,
&has_big_component, &has_big_component,
&has_small_component, &has_small_component](const CandidateSegment &segment) {
&use_all_edges](const CandidateSegment &segment) {
auto use_segment = auto use_segment =
(!has_small_component || (!has_big_component && !IsTinyComponent(segment))); (!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
auto use_directions = std::make_pair(use_segment, use_segment); auto use_directions = std::make_pair(use_segment, use_segment);
const auto admissible_segments = CheckSegmentExclude(segment); const auto admissible_segments = CheckSegmentExclude(segment);
use_directions = boolPairAnd(use_directions, HasValidEdge(segment, use_all_edges)); use_directions = boolPairAnd(use_directions, HasValidEdge(segment));
if (use_segment) if (use_segment)
{ {
@@ -373,13 +341,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
} }
BOOST_ASSERT(results.size() > 0); BOOST_ASSERT(results.size() > 0);
return std::make_pair( return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node,
MakePhantomNode( MakePhantomNode(input_coordinate, results.back()).phantom_node);
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
@@ -389,10 +352,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
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
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;
@@ -404,13 +364,12 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
bearing, bearing,
bearing_range, bearing_range,
&has_big_component, &has_big_component,
&has_small_component, &has_small_component](const CandidateSegment &segment) {
&use_all_edges](const CandidateSegment &segment) {
auto use_segment = auto use_segment =
(!has_small_component || (!has_big_component && !IsTinyComponent(segment))); (!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
auto use_directions = std::make_pair(use_segment, use_segment); auto use_directions = std::make_pair(use_segment, use_segment);
const auto admissible_segments = CheckSegmentExclude(segment); const auto admissible_segments = CheckSegmentExclude(segment);
use_directions = boolPairAnd(use_directions, HasValidEdge(segment, use_all_edges)); use_directions = boolPairAnd(use_directions, HasValidEdge(segment));
if (use_segment) if (use_segment)
{ {
@@ -442,13 +401,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
} }
BOOST_ASSERT(results.size() > 0); BOOST_ASSERT(results.size() > 0);
return std::make_pair( return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node,
MakePhantomNode( MakePhantomNode(input_coordinate, results.back()).phantom_node);
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:
@@ -467,9 +421,7 @@ 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 EdgeData &data) const
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;
@@ -508,21 +460,15 @@ 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});
// For measuring distance from begin up to end EdgeDistance forward_distance_offset = 0;
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()));
@@ -543,9 +489,15 @@ 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 = EdgeDistance reverse_distance_offset = 0;
appx_distance(forward_geometry.begin() + data.fwd_segment_position + 1, for (auto current = forward_geometry.begin();
std::prev(forward_geometry.end())); current < forward_geometry.end() - data.fwd_segment_position - 2;
++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];
@@ -555,64 +507,16 @@ 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
@@ -643,8 +547,6 @@ 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,
@@ -726,8 +628,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
* which means that this edge is not currently traversible. If this is the case, * which means that this edge is not currently traversible. If this is the case,
* then we shouldn't snap to this edge. * then we shouldn't snap to this edge.
*/ */
std::pair<bool, bool> HasValidEdge(const CandidateSegment &segment, std::pair<bool, bool> HasValidEdge(const CandidateSegment &segment) const
const bool use_all_edges = false) const
{ {
bool forward_edge_valid = false; bool forward_edge_valid = false;
@@ -751,9 +652,6 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
reverse_edge_valid = data.reverse_segment_id.enabled; reverse_edge_valid = data.reverse_segment_id.enabled;
} }
forward_edge_valid = forward_edge_valid && (data.is_startpoint || use_all_edges);
reverse_edge_valid = reverse_edge_valid && (data.is_startpoint || use_all_edges);
return std::make_pair(forward_edge_valid, reverse_edge_valid); return std::make_pair(forward_edge_valid, reverse_edge_valid);
} }
@@ -795,7 +693,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
const CoordinateList &coordinates; const CoordinateList &coordinates;
DataFacadeT &datafacade; DataFacadeT &datafacade;
}; };
} // namespace engine }
} // namespace osrm }
#endif #endif
+2 -9
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
// captured by the phantom node. So we need to add the target duration here. // caputed 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,13 +182,6 @@ 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) == sizeof(PhantomNode) + 4, "Hint is bigger than expected"); static_assert(sizeof(Hint) == 80 + 4, "Hint is bigger than expected");
constexpr std::size_t ENCODED_HINT_SIZE = 124; constexpr std::size_t ENCODED_HINT_SIZE = 112;
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
+16 -24
View File
@@ -50,10 +50,9 @@ 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), forward_duration_penalty(0), forward_duration_offset(0), reverse_duration_offset(0), fwd_segment_position(0),
reverse_duration_penalty(0), fwd_segment_position(0), is_valid_forward_source{false}, is_valid_forward_source{false}, is_valid_forward_target{false},
is_valid_forward_target{false}, is_valid_reverse_source{false}, is_valid_reverse_source{false}, is_valid_reverse_target{false}, bearing(0)
is_valid_reverse_target{false}, bearing(0)
{ {
} }
@@ -70,13 +69,13 @@ struct PhantomNode
return reverse_weight_offset + reverse_weight; return reverse_weight_offset + reverse_weight;
} }
EdgeDuration GetForwardDuration() const EdgeWeight 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;
} }
EdgeDuration GetReverseDuration() const EdgeWeight 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;
@@ -164,12 +163,10 @@ struct PhantomNode
EdgeDistance reverse_distance, EdgeDistance reverse_distance,
EdgeDistance forward_distance_offset, EdgeDistance forward_distance_offset,
EdgeDistance reverse_distance_offset, EdgeDistance reverse_distance_offset,
EdgeDuration forward_duration, EdgeWeight forward_duration,
EdgeDuration reverse_duration, EdgeWeight reverse_duration,
EdgeDuration forward_duration_offset, EdgeWeight forward_duration_offset,
EdgeDuration reverse_duration_offset, EdgeWeight 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,
@@ -185,8 +182,6 @@ 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},
@@ -206,13 +201,10 @@ 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
EdgeDuration forward_duration; EdgeWeight forward_duration;
EdgeDuration reverse_duration; EdgeWeight reverse_duration;
EdgeDuration forward_duration_offset; // TODO: try to remove -> requires path unpacking changes EdgeWeight forward_duration_offset; // TODO: try to remove -> requires path unpacking changes
EdgeDuration reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes EdgeWeight 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
@@ -227,7 +219,7 @@ struct PhantomNode
unsigned short bearing : 12; unsigned short bearing : 12;
}; };
static_assert(sizeof(PhantomNode) == 88, "PhantomNode has more padding then expected"); static_assert(sizeof(PhantomNode) == 80, "PhantomNode has more padding then expected");
using PhantomNodePair = std::pair<PhantomNode, PhantomNode>; using PhantomNodePair = std::pair<PhantomNode, PhantomNode>;
@@ -242,7 +234,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
+7 -25
View File
@@ -138,8 +138,7 @@ class BasePlugin
std::vector<std::vector<PhantomNodeWithDistance>> std::vector<std::vector<PhantomNodeWithDistance>>
GetPhantomNodesInRange(const datafacade::BaseDataFacade &facade, GetPhantomNodesInRange(const datafacade::BaseDataFacade &facade,
const api::BaseParameters &parameters, const api::BaseParameters &parameters,
const std::vector<double> radiuses, const std::vector<double> radiuses) const
bool use_all_edges = false) const
{ {
std::vector<std::vector<PhantomNodeWithDistance>> phantom_nodes( std::vector<std::vector<PhantomNodeWithDistance>> phantom_nodes(
parameters.coordinates.size()); parameters.coordinates.size());
@@ -172,13 +171,12 @@ class BasePlugin
radiuses[i], radiuses[i],
parameters.bearings[i]->bearing, parameters.bearings[i]->bearing,
parameters.bearings[i]->range, parameters.bearings[i]->range,
approach, approach);
use_all_edges);
} }
else else
{ {
phantom_nodes[i] = facade.NearestPhantomNodesInRange( phantom_nodes[i] = facade.NearestPhantomNodesInRange(
parameters.coordinates[i], radiuses[i], approach, use_all_edges); parameters.coordinates[i], radiuses[i], approach);
} }
} }
@@ -270,7 +268,6 @@ class BasePlugin
const bool use_bearings = !parameters.bearings.empty(); const bool use_bearings = !parameters.bearings.empty();
const bool use_radiuses = !parameters.radiuses.empty(); const bool use_radiuses = !parameters.radiuses.empty();
const bool use_approaches = !parameters.approaches.empty(); const bool use_approaches = !parameters.approaches.empty();
const bool use_all_edges = parameters.snapping == api::BaseParameters::SnappingType::Any;
BOOST_ASSERT(parameters.IsValid()); BOOST_ASSERT(parameters.IsValid());
for (const auto i : util::irange<std::size_t>(0UL, parameters.coordinates.size())) for (const auto i : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
@@ -297,10 +294,7 @@ class BasePlugin
*parameters.radiuses[i], *parameters.radiuses[i],
parameters.bearings[i]->bearing, parameters.bearings[i]->bearing,
parameters.bearings[i]->range, parameters.bearings[i]->range,
approach, approach);
use_all_edges,
parameters.min_stoppage_penalty,
parameters.max_stoppage_penalty);
} }
else else
{ {
@@ -309,10 +303,7 @@ class BasePlugin
parameters.coordinates[i], parameters.coordinates[i],
parameters.bearings[i]->bearing, parameters.bearings[i]->bearing,
parameters.bearings[i]->range, parameters.bearings[i]->range,
approach, approach);
use_all_edges,
parameters.min_stoppage_penalty,
parameters.max_stoppage_penalty);
} }
} }
else else
@@ -321,22 +312,13 @@ class BasePlugin
{ {
phantom_node_pairs[i] = phantom_node_pairs[i] =
facade.NearestPhantomNodeWithAlternativeFromBigComponent( facade.NearestPhantomNodeWithAlternativeFromBigComponent(
parameters.coordinates[i], parameters.coordinates[i], *parameters.radiuses[i], approach);
*parameters.radiuses[i],
approach,
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], parameters.coordinates[i], approach);
approach,
use_all_edges,
parameters.min_stoppage_penalty,
parameters.max_stoppage_penalty);
} }
} }
+8 -4
View File
@@ -34,7 +34,8 @@ class RoutingAlgorithmsInterface
ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes, ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes,
const std::vector<std::size_t> &source_indices, const std::vector<std::size_t> &source_indices,
const std::vector<std::size_t> &target_indices, const std::vector<std::size_t> &target_indices,
const bool calculate_distance) const = 0; const bool calculate_distance,
const bool calculate_duration) const = 0;
virtual routing_algorithms::SubMatchingList virtual routing_algorithms::SubMatchingList
MapMatching(const routing_algorithms::CandidateLists &candidates_list, MapMatching(const routing_algorithms::CandidateLists &candidates_list,
@@ -87,7 +88,8 @@ template <typename Algorithm> class RoutingAlgorithms final : public RoutingAlgo
ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes, ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes,
const std::vector<std::size_t> &source_indices, const std::vector<std::size_t> &source_indices,
const std::vector<std::size_t> &target_indices, const std::vector<std::size_t> &target_indices,
const bool calculate_distance) const final override; const bool calculate_distance,
const bool calculate_duration) const final override;
routing_algorithms::SubMatchingList routing_algorithms::SubMatchingList
MapMatching(const routing_algorithms::CandidateLists &candidates_list, MapMatching(const routing_algorithms::CandidateLists &candidates_list,
@@ -196,7 +198,8 @@ std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>>
RoutingAlgorithms<Algorithm>::ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes, RoutingAlgorithms<Algorithm>::ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes,
const std::vector<std::size_t> &_source_indices, const std::vector<std::size_t> &_source_indices,
const std::vector<std::size_t> &_target_indices, const std::vector<std::size_t> &_target_indices,
const bool calculate_distance) const const bool calculate_distance,
const bool calculate_duration) const
{ {
BOOST_ASSERT(!phantom_nodes.empty()); BOOST_ASSERT(!phantom_nodes.empty());
@@ -219,7 +222,8 @@ RoutingAlgorithms<Algorithm>::ManyToManySearch(const std::vector<PhantomNode> &p
phantom_nodes, phantom_nodes,
std::move(source_indices), std::move(source_indices),
std::move(target_indices), std::move(target_indices),
calculate_distance); calculate_distance,
calculate_duration);
} }
template <typename Algorithm> template <typename Algorithm>
@@ -25,17 +25,15 @@ struct NodeBucket
unsigned from_clique_arc : 1; unsigned from_clique_arc : 1;
EdgeWeight weight; EdgeWeight weight;
EdgeDuration duration; EdgeDuration duration;
EdgeDistance distance;
NodeBucket(NodeID middle_node, NodeBucket(NodeID middle_node,
NodeID parent_node, NodeID parent_node,
bool from_clique_arc, bool from_clique_arc,
unsigned column_index, unsigned column_index,
EdgeWeight weight, EdgeWeight weight,
EdgeDuration duration, EdgeDuration duration)
EdgeDistance distance)
: middle_node(middle_node), parent_node(parent_node), column_index(column_index), : middle_node(middle_node), parent_node(parent_node), column_index(column_index),
from_clique_arc(from_clique_arc), weight(weight), duration(duration), distance(distance) from_clique_arc(from_clique_arc), weight(weight), duration(duration)
{ {
} }
@@ -43,10 +41,9 @@ struct NodeBucket
NodeID parent_node, NodeID parent_node,
unsigned column_index, unsigned column_index,
EdgeWeight weight, EdgeWeight weight,
EdgeDuration duration, EdgeDuration duration)
EdgeDistance distance)
: middle_node(middle_node), parent_node(parent_node), column_index(column_index), : middle_node(middle_node), parent_node(parent_node), column_index(column_index),
from_clique_arc(false), weight(weight), duration(duration), distance(distance) from_clique_arc(false), weight(weight), duration(duration)
{ {
} }
@@ -97,7 +94,8 @@ manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
const std::vector<PhantomNode> &phantom_nodes, const std::vector<PhantomNode> &phantom_nodes,
const std::vector<std::size_t> &source_indices, const std::vector<std::size_t> &source_indices,
const std::vector<std::size_t> &target_indices, const std::vector<std::size_t> &target_indices,
const bool calculate_distance); const bool calculate_distance,
const bool calculate_duration);
} // namespace routing_algorithms } // namespace routing_algorithms
} // namespace engine } // namespace engine
@@ -85,17 +85,13 @@ 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()});
} }
if (phantom_node.IsValidReverseSource()) if (phantom_node.IsValidReverseSource())
{ {
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()});
} }
} }
@@ -106,17 +102,13 @@ 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()});
} }
if (phantom_node.IsValidReverseTarget()) if (phantom_node.IsValidReverseTarget())
{ {
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()});
} }
} }
@@ -186,10 +186,9 @@ void routingStep(const DataFacade<Algorithm> &facade,
} }
template <bool UseDuration> template <bool UseDuration>
std::tuple<EdgeWeight, EdgeDistance> getLoopWeight(const DataFacade<Algorithm> &facade, NodeID node) EdgeWeight getLoopWeight(const DataFacade<Algorithm> &facade, NodeID node)
{ {
EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT; EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT;
EdgeDistance loop_distance = MAXIMAL_EDGE_DISTANCE;
for (auto edge : facade.GetAdjacentEdgeRange(node)) for (auto edge : facade.GetAdjacentEdgeRange(node))
{ {
const auto &data = facade.GetEdgeData(edge); const auto &data = facade.GetEdgeData(edge);
@@ -199,15 +198,11 @@ std::tuple<EdgeWeight, EdgeDistance> getLoopWeight(const DataFacade<Algorithm> &
if (to == node) if (to == node)
{ {
const auto value = UseDuration ? data.duration : data.weight; const auto value = UseDuration ? data.duration : data.weight;
if (value < loop_weight) loop_weight = std::min(loop_weight, value);
{
loop_weight = value;
loop_distance = data.distance;
}
} }
} }
} }
return std::make_tuple(loop_weight, loop_distance); return loop_weight;
} }
/** /**
@@ -509,6 +509,90 @@ UnpackedPath search(SearchEngineData<Algorithm> &engine_working_data,
return std::make_tuple(weight, std::move(unpacked_nodes), std::move(unpacked_edges)); return std::make_tuple(weight, std::move(unpacked_nodes), std::move(unpacked_edges));
} }
// With (s, middle, t) we trace back the paths middle -> s and middle -> t.
// This gives us a packed path (node ids) from the base graph around s and t,
// and overlay node ids otherwise. We then have to unpack the overlay clique
// edges by recursively descending unpacking the path down to the base graph.
using UnpackedNodes = std::vector<NodeID>;
using UnpackedEdges = std::vector<EdgeID>;
using UnpackedPath = std::tuple<EdgeWeight, UnpackedNodes, UnpackedEdges>;
template <typename Algorithm, typename... Args>
UnpackedPath
unpackPathAndCalculateDistance(SearchEngineData<Algorithm> &engine_working_data,
const DataFacade<Algorithm> &facade,
typename SearchEngineData<Algorithm>::QueryHeap &forward_heap,
typename SearchEngineData<Algorithm>::QueryHeap &reverse_heap,
const bool force_loop_forward,
const bool force_loop_reverse,
EdgeWeight weight_upper_bound,
PackedPath packed_path,
NodeID middle,
Args... args)
{
EdgeWeight weight = weight_upper_bound;
const auto &partition = facade.GetMultiLevelPartition();
const NodeID source_node = !packed_path.empty() ? std::get<0>(packed_path.front()) : middle;
// Unpack path
std::vector<NodeID> unpacked_nodes;
std::vector<EdgeID> unpacked_edges;
unpacked_nodes.reserve(packed_path.size());
unpacked_edges.reserve(packed_path.size());
unpacked_nodes.push_back(source_node);
for (auto const &packed_edge : packed_path)
{
NodeID source, target;
bool overlay_edge;
std::tie(source, target, overlay_edge) = packed_edge;
if (!overlay_edge)
{ // a base graph edge
unpacked_nodes.push_back(target);
unpacked_edges.push_back(facade.FindEdge(source, target));
}
else
{ // an overlay graph edge
LevelID level = getNodeQueryLevel(partition, source, args...);
CellID parent_cell_id = partition.GetCell(level, source);
BOOST_ASSERT(parent_cell_id == partition.GetCell(level, target));
LevelID sublevel = level - 1;
// Here heaps can be reused, let's go deeper!
forward_heap.Clear();
reverse_heap.Clear();
forward_heap.Insert(source, 0, {source});
reverse_heap.Insert(target, 0, {target});
// TODO: when structured bindings will be allowed change to
// auto [subpath_weight, subpath_source, subpath_target, subpath] = ...
EdgeWeight subpath_weight;
std::vector<NodeID> subpath_nodes;
std::vector<EdgeID> subpath_edges;
std::tie(subpath_weight, subpath_nodes, subpath_edges) = search(engine_working_data,
facade,
forward_heap,
reverse_heap,
force_loop_forward,
force_loop_reverse,
weight_upper_bound,
sublevel,
parent_cell_id);
BOOST_ASSERT(!subpath_edges.empty());
BOOST_ASSERT(subpath_nodes.size() > 1);
BOOST_ASSERT(subpath_nodes.front() == source);
BOOST_ASSERT(subpath_nodes.back() == target);
unpacked_nodes.insert(
unpacked_nodes.end(), std::next(subpath_nodes.begin()), subpath_nodes.end());
unpacked_edges.insert(unpacked_edges.end(), subpath_edges.begin(), subpath_edges.end());
}
}
return std::make_tuple(weight, std::move(unpacked_nodes), std::move(unpacked_edges));
}
// Alias to be compatible with the CH-based search // Alias to be compatible with the CH-based search
template <typename Algorithm> template <typename Algorithm>
inline void search(SearchEngineData<Algorithm> &engine_working_data, inline void search(SearchEngineData<Algorithm> &engine_working_data,
+5 -13
View File
@@ -30,11 +30,7 @@ struct HeapData
struct ManyToManyHeapData : HeapData struct ManyToManyHeapData : HeapData
{ {
EdgeWeight duration; EdgeWeight duration;
EdgeDistance distance; ManyToManyHeapData(NodeID p, EdgeWeight duration) : HeapData(p), duration(duration) {}
ManyToManyHeapData(NodeID p, EdgeWeight duration, EdgeDistance distance)
: HeapData(p), duration(duration), distance(distance)
{
}
}; };
template <> struct SearchEngineData<routing_algorithms::ch::Algorithm> template <> struct SearchEngineData<routing_algorithms::ch::Algorithm>
@@ -79,16 +75,12 @@ struct MultiLayerDijkstraHeapData
struct ManyToManyMultiLayerDijkstraHeapData : MultiLayerDijkstraHeapData struct ManyToManyMultiLayerDijkstraHeapData : MultiLayerDijkstraHeapData
{ {
EdgeWeight duration; EdgeWeight duration;
EdgeDistance distance; ManyToManyMultiLayerDijkstraHeapData(NodeID p, EdgeWeight duration)
ManyToManyMultiLayerDijkstraHeapData(NodeID p, EdgeWeight duration, EdgeDistance distance) : MultiLayerDijkstraHeapData(p), duration(duration)
: MultiLayerDijkstraHeapData(p), duration(duration), distance(distance)
{ {
} }
ManyToManyMultiLayerDijkstraHeapData(NodeID p, ManyToManyMultiLayerDijkstraHeapData(NodeID p, bool from, EdgeWeight duration)
bool from, : MultiLayerDijkstraHeapData(p, from), duration(duration)
EdgeWeight duration,
EdgeDistance distance)
: MultiLayerDijkstraHeapData(p, from), duration(duration), distance(distance)
{ {
} }
}; };
+5 -12
View File
@@ -15,25 +15,20 @@ struct EdgeBasedEdge
public: public:
struct EdgeData struct EdgeData
{ {
EdgeData() EdgeData() : turn_id(0), weight(0), duration(0), forward(false), backward(false) {}
: turn_id(0), weight(0), distance(0), duration(0), forward(false), backward(false)
{
}
EdgeData(const NodeID turn_id, EdgeData(const NodeID turn_id,
const EdgeWeight weight, const EdgeWeight weight,
const EdgeDistance distance,
const EdgeWeight duration, const EdgeWeight duration,
const bool forward, const bool forward,
const bool backward) const bool backward)
: turn_id(turn_id), weight(weight), distance(distance), duration(duration), : turn_id(turn_id), weight(weight), duration(duration), forward(forward),
forward(forward), backward(backward) backward(backward)
{ {
} }
NodeID turn_id; // ID of the edge based node (node based edge) NodeID turn_id; // ID of the edge based node (node based edge)
EdgeWeight weight; EdgeWeight weight;
EdgeDistance distance;
EdgeWeight duration : 30; EdgeWeight duration : 30;
std::uint32_t forward : 1; std::uint32_t forward : 1;
std::uint32_t backward : 1; std::uint32_t backward : 1;
@@ -48,7 +43,6 @@ struct EdgeBasedEdge
const NodeID edge_id, const NodeID edge_id,
const EdgeWeight weight, const EdgeWeight weight,
const EdgeWeight duration, const EdgeWeight duration,
const EdgeDistance distance,
const bool forward, const bool forward,
const bool backward); const bool backward);
EdgeBasedEdge(const NodeID source, const NodeID target, const EdgeBasedEdge::EdgeData &data); EdgeBasedEdge(const NodeID source, const NodeID target, const EdgeBasedEdge::EdgeData &data);
@@ -59,7 +53,7 @@ struct EdgeBasedEdge
NodeID target; NodeID target;
EdgeData data; EdgeData data;
}; };
static_assert(sizeof(extractor::EdgeBasedEdge) == 24, static_assert(sizeof(extractor::EdgeBasedEdge) == 20,
"Size of extractor::EdgeBasedEdge type is " "Size of extractor::EdgeBasedEdge type is "
"bigger than expected. This will influence " "bigger than expected. This will influence "
"memory consumption."); "memory consumption.");
@@ -73,10 +67,9 @@ inline EdgeBasedEdge::EdgeBasedEdge(const NodeID source,
const NodeID turn_id, const NodeID turn_id,
const EdgeWeight weight, const EdgeWeight weight,
const EdgeWeight duration, const EdgeWeight duration,
const EdgeDistance distance,
const bool forward, const bool forward,
const bool backward) const bool backward)
: source(source), target(target), data{turn_id, weight, distance, duration, forward, backward} : source(source), target(target), data{turn_id, weight, duration, forward, backward}
{ {
} }
@@ -89,9 +89,9 @@ class EdgeBasedGraphFactory
// The following get access functions destroy the content in the factory // The following get access functions destroy the content in the factory
void GetEdgeBasedEdges(util::DeallocatingVector<EdgeBasedEdge> &edges); void GetEdgeBasedEdges(util::DeallocatingVector<EdgeBasedEdge> &edges);
void GetEdgeBasedNodeSegments(std::vector<EdgeBasedNodeSegment> &nodes); void GetEdgeBasedNodeSegments(std::vector<EdgeBasedNodeSegment> &nodes);
void GetStartPointMarkers(std::vector<bool> &node_is_startpoint);
void GetEdgeBasedNodeWeights(std::vector<EdgeWeight> &output_node_weights); void GetEdgeBasedNodeWeights(std::vector<EdgeWeight> &output_node_weights);
void GetEdgeBasedNodeDurations(std::vector<EdgeWeight> &output_node_durations); void GetEdgeBasedNodeDurations(std::vector<EdgeWeight> &output_node_durations);
void GetEdgeBasedNodeDistances(std::vector<EdgeDistance> &output_node_distances);
std::uint32_t GetConnectivityChecksum() const; std::uint32_t GetConnectivityChecksum() const;
std::uint64_t GetNumberOfEdgeBasedNodes() const; std::uint64_t GetNumberOfEdgeBasedNodes() const;
@@ -111,11 +111,14 @@ class EdgeBasedGraphFactory
std::vector<ConditionalTurnPenalty> std::vector<ConditionalTurnPenalty>
IndexConditionals(std::vector<Conditional> &&conditionals) const; IndexConditionals(std::vector<Conditional> &&conditionals) const;
//! maps index from m_edge_based_node_list to ture/false if the node is an entry point to the
//! graph
std::vector<bool> m_edge_based_node_is_startpoint;
//! node weights that indicate the length of the segment (node based) represented by the //! node weights that indicate the length of the segment (node based) represented by the
//! edge-based node //! edge-based node
std::vector<EdgeWeight> m_edge_based_node_weights; std::vector<EdgeWeight> m_edge_based_node_weights;
std::vector<EdgeDuration> m_edge_based_node_durations; std::vector<EdgeDuration> m_edge_based_node_durations;
std::vector<EdgeDistance> m_edge_based_node_distances;
//! list of edge based nodes (compressed segments) //! list of edge based nodes (compressed segments)
std::vector<EdgeBasedNodeSegment> m_edge_based_node_segments; std::vector<EdgeBasedNodeSegment> m_edge_based_node_segments;
@@ -22,9 +22,7 @@ struct EdgeBasedNodeSegment
EdgeBasedNodeSegment() EdgeBasedNodeSegment()
: forward_segment_id{SPECIAL_SEGMENTID, false}, : forward_segment_id{SPECIAL_SEGMENTID, false},
reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID), v(SPECIAL_NODEID), reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID), v(SPECIAL_NODEID),
fwd_segment_position(std::numeric_limits<unsigned short>::max() >> fwd_segment_position(std::numeric_limits<unsigned short>::max())
1), // >> 1 because we've only got 15 bits
is_startpoint(false)
{ {
} }
@@ -32,10 +30,9 @@ struct EdgeBasedNodeSegment
const SegmentID reverse_segment_id_, const SegmentID reverse_segment_id_,
NodeID u, NodeID u,
NodeID v, NodeID v,
unsigned short fwd_segment_position, unsigned short fwd_segment_position)
bool is_startpoint_)
: forward_segment_id(forward_segment_id_), reverse_segment_id(reverse_segment_id_), u(u), : forward_segment_id(forward_segment_id_), reverse_segment_id(reverse_segment_id_), u(u),
v(v), fwd_segment_position(fwd_segment_position), is_startpoint(is_startpoint_) v(v), fwd_segment_position(fwd_segment_position)
{ {
BOOST_ASSERT(forward_segment_id.enabled || reverse_segment_id.enabled); BOOST_ASSERT(forward_segment_id.enabled || reverse_segment_id.enabled);
} }
@@ -44,8 +41,7 @@ struct EdgeBasedNodeSegment
SegmentID reverse_segment_id; // edge-based graph node ID in reverse direction (v->u if exists) SegmentID reverse_segment_id; // edge-based graph node ID in reverse direction (v->u if exists)
NodeID u; // node-based graph node ID of the start node NodeID u; // node-based graph node ID of the start node
NodeID v; // node-based graph node ID of the target node NodeID v; // node-based graph node ID of the target node
unsigned short fwd_segment_position : 15; // segment id in a compressed geometry unsigned short fwd_segment_position; // segment id in a compressed geometry
bool is_startpoint : 1;
}; };
} }
} }
+2 -1
View File
@@ -85,9 +85,9 @@ class Extractor
// output data // output data
EdgeBasedNodeDataContainer &edge_based_nodes_container, EdgeBasedNodeDataContainer &edge_based_nodes_container,
std::vector<EdgeBasedNodeSegment> &edge_based_node_segments, std::vector<EdgeBasedNodeSegment> &edge_based_node_segments,
std::vector<bool> &node_is_startpoint,
std::vector<EdgeWeight> &edge_based_node_weights, std::vector<EdgeWeight> &edge_based_node_weights,
std::vector<EdgeDuration> &edge_based_node_durations, std::vector<EdgeDuration> &edge_based_node_durations,
std::vector<EdgeDistance> &edge_based_node_distances,
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list, util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
std::uint32_t &connectivity_checksum); std::uint32_t &connectivity_checksum);
@@ -96,6 +96,7 @@ class Extractor
const std::vector<EdgeBasedNodeSegment> &input_node_segments, const std::vector<EdgeBasedNodeSegment> &input_node_segments,
EdgeBasedNodeDataContainer &nodes_container) const; EdgeBasedNodeDataContainer &nodes_container) const;
void BuildRTree(std::vector<EdgeBasedNodeSegment> edge_based_node_segments, void BuildRTree(std::vector<EdgeBasedNodeSegment> edge_based_node_segments,
std::vector<bool> node_is_startpoint,
const std::vector<util::Coordinate> &coordinates); const std::vector<util::Coordinate> &coordinates);
std::shared_ptr<RestrictionMap> LoadRestrictionMap(); std::shared_ptr<RestrictionMap> LoadRestrictionMap();
+6 -30
View File
@@ -453,8 +453,8 @@ void writeNames(const boost::filesystem::path &path, const NameTableT &table)
serialization::write(writer, "/common/names", table); serialization::write(writer, "/common/names", table);
} }
template <typename NodeWeightsVectorT> template <typename NodeWeigtsVectorT>
void readEdgeBasedNodeWeights(const boost::filesystem::path &path, NodeWeightsVectorT &weights) void readEdgeBasedNodeWeights(const boost::filesystem::path &path, NodeWeigtsVectorT &weights)
{ {
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
storage::tar::FileReader reader{path, fingerprint}; storage::tar::FileReader reader{path, fingerprint};
@@ -462,33 +462,9 @@ void readEdgeBasedNodeWeights(const boost::filesystem::path &path, NodeWeightsVe
storage::serialization::read(reader, "/extractor/edge_based_node_weights", weights); storage::serialization::read(reader, "/extractor/edge_based_node_weights", weights);
} }
template <typename NodeDistancesVectorT> template <typename NodeWeigtsVectorT, typename NodeDurationsVectorT>
void readEdgeBasedNodeDistances(const boost::filesystem::path &path,
NodeDistancesVectorT &distances)
{
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
storage::tar::FileReader reader{path, fingerprint};
storage::serialization::read(reader, "/extractor/edge_based_node_distances", distances);
}
template <typename NodeWeightsVectorT, typename NodeDurationsVectorT, typename NodeDistancesVectorT>
void writeEdgeBasedNodeWeightsDurationsDistances(const boost::filesystem::path &path,
const NodeWeightsVectorT &weights,
const NodeDurationsVectorT &durations,
const NodeDistancesVectorT &distances)
{
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
storage::tar::FileWriter writer{path, fingerprint};
storage::serialization::write(writer, "/extractor/edge_based_node_weights", weights);
storage::serialization::write(writer, "/extractor/edge_based_node_durations", durations);
storage::serialization::write(writer, "/extractor/edge_based_node_distances", distances);
}
template <typename NodeWeightsVectorT, typename NodeDurationsVectorT>
void readEdgeBasedNodeWeightsDurations(const boost::filesystem::path &path, void readEdgeBasedNodeWeightsDurations(const boost::filesystem::path &path,
NodeWeightsVectorT &weights, NodeWeigtsVectorT &weights,
NodeDurationsVectorT &durations) NodeDurationsVectorT &durations)
{ {
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
@@ -498,9 +474,9 @@ void readEdgeBasedNodeWeightsDurations(const boost::filesystem::path &path,
storage::serialization::read(reader, "/extractor/edge_based_node_durations", durations); storage::serialization::read(reader, "/extractor/edge_based_node_durations", durations);
} }
template <typename NodeWeightsVectorT, typename NodeDurationsVectorT> template <typename NodeWeigtsVectorT, typename NodeDurationsVectorT>
void writeEdgeBasedNodeWeightsDurations(const boost::filesystem::path &path, void writeEdgeBasedNodeWeightsDurations(const boost::filesystem::path &path,
const NodeWeightsVectorT &weights, const NodeWeigtsVectorT &weights,
const NodeDurationsVectorT &durations) const NodeDurationsVectorT &durations)
{ {
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
@@ -63,7 +63,7 @@ struct InternalExtractorEdge
WeightData weight_data, WeightData weight_data,
DurationData duration_data, DurationData duration_data,
util::Coordinate source_coordinate) util::Coordinate source_coordinate)
: result(source, target, 0, 0, 0, {}, -1, {}), weight_data(std::move(weight_data)), : result(source, target, 0, 0, {}, -1, {}), weight_data(std::move(weight_data)),
duration_data(std::move(duration_data)), source_coordinate(std::move(source_coordinate)) duration_data(std::move(duration_data)), source_coordinate(std::move(source_coordinate))
{ {
} }
+6 -18
View File
@@ -97,7 +97,6 @@ struct NodeBasedEdge
NodeID target, NodeID target,
EdgeWeight weight, EdgeWeight weight,
EdgeDuration duration, EdgeDuration duration,
EdgeDistance distance,
GeometryID geometry_id, GeometryID geometry_id,
AnnotationID annotation_data, AnnotationID annotation_data,
NodeBasedEdgeClassification flags); NodeBasedEdgeClassification flags);
@@ -108,7 +107,6 @@ struct NodeBasedEdge
NodeID target; // 32 4 NodeID target; // 32 4
EdgeWeight weight; // 32 4 EdgeWeight weight; // 32 4
EdgeDuration duration; // 32 4 EdgeDuration duration; // 32 4
EdgeDistance distance; // 32 4
GeometryID geometry_id; // 32 4 GeometryID geometry_id; // 32 4
AnnotationID annotation_data; // 32 4 AnnotationID annotation_data; // 32 4
NodeBasedEdgeClassification flags; // 32 4 NodeBasedEdgeClassification flags; // 32 4
@@ -122,7 +120,6 @@ struct NodeBasedEdgeWithOSM : NodeBasedEdge
OSMNodeID target, OSMNodeID target,
EdgeWeight weight, EdgeWeight weight,
EdgeDuration duration, EdgeDuration duration,
EdgeDistance distance,
GeometryID geometry_id, GeometryID geometry_id,
AnnotationID annotation_data, AnnotationID annotation_data,
NodeBasedEdgeClassification flags); NodeBasedEdgeClassification flags);
@@ -140,8 +137,7 @@ inline NodeBasedEdgeClassification::NodeBasedEdgeClassification()
} }
inline NodeBasedEdge::NodeBasedEdge() inline NodeBasedEdge::NodeBasedEdge()
: source(SPECIAL_NODEID), target(SPECIAL_NODEID), weight(0), duration(0), distance(0), : source(SPECIAL_NODEID), target(SPECIAL_NODEID), weight(0), duration(0), annotation_data(-1)
annotation_data(-1)
{ {
} }
@@ -149,12 +145,11 @@ inline NodeBasedEdge::NodeBasedEdge(NodeID source,
NodeID target, NodeID target,
EdgeWeight weight, EdgeWeight weight,
EdgeDuration duration, EdgeDuration duration,
EdgeDistance distance,
GeometryID geometry_id, GeometryID geometry_id,
AnnotationID annotation_data, AnnotationID annotation_data,
NodeBasedEdgeClassification flags) NodeBasedEdgeClassification flags)
: source(source), target(target), weight(weight), duration(duration), distance(distance), : source(source), target(target), weight(weight), duration(duration), geometry_id(geometry_id),
geometry_id(geometry_id), annotation_data(annotation_data), flags(flags) annotation_data(annotation_data), flags(flags)
{ {
} }
@@ -180,18 +175,11 @@ inline NodeBasedEdgeWithOSM::NodeBasedEdgeWithOSM(OSMNodeID source,
OSMNodeID target, OSMNodeID target,
EdgeWeight weight, EdgeWeight weight,
EdgeDuration duration, EdgeDuration duration,
EdgeDistance distance,
GeometryID geometry_id, GeometryID geometry_id,
AnnotationID annotation_data, AnnotationID annotation_data,
NodeBasedEdgeClassification flags) NodeBasedEdgeClassification flags)
: NodeBasedEdge(SPECIAL_NODEID, : NodeBasedEdge(
SPECIAL_NODEID, SPECIAL_NODEID, SPECIAL_NODEID, weight, duration, geometry_id, annotation_data, flags),
weight,
duration,
distance,
geometry_id,
annotation_data,
flags),
osm_source_id(std::move(source)), osm_target_id(std::move(target)) osm_source_id(std::move(source)), osm_target_id(std::move(target))
{ {
} }
@@ -201,7 +189,7 @@ inline NodeBasedEdgeWithOSM::NodeBasedEdgeWithOSM()
{ {
} }
static_assert(sizeof(extractor::NodeBasedEdge) == 32, static_assert(sizeof(extractor::NodeBasedEdge) == 28,
"Size of extractor::NodeBasedEdge type is " "Size of extractor::NodeBasedEdge type is "
"bigger than expected. This will influence " "bigger than expected. This will influence "
"memory consumption."); "memory consumption.");
-81
View File
@@ -1,81 +0,0 @@
#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
+5 -222
View File
@@ -2,7 +2,6 @@
#define OSRM_BINDINGS_NODE_SUPPORT_HPP #define OSRM_BINDINGS_NODE_SUPPORT_HPP
#include "nodejs/json_v8_renderer.hpp" #include "nodejs/json_v8_renderer.hpp"
#include "util/json_renderer.hpp"
#include "osrm/approach.hpp" #include "osrm/approach.hpp"
#include "osrm/bearing.hpp" #include "osrm/bearing.hpp"
@@ -25,7 +24,6 @@
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
#include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -44,13 +42,6 @@ using match_parameters_ptr = std::unique_ptr<osrm::MatchParameters>;
using nearest_parameters_ptr = std::unique_ptr<osrm::NearestParameters>; using nearest_parameters_ptr = std::unique_ptr<osrm::NearestParameters>;
using table_parameters_ptr = std::unique_ptr<osrm::TableParameters>; using table_parameters_ptr = std::unique_ptr<osrm::TableParameters>;
struct PluginParameters
{
bool renderJSONToBuffer = false;
};
using ObjectOrString = typename mapbox::util::variant<osrm::json::Object, std::string>;
template <typename ResultT> inline v8::Local<v8::Value> render(const ResultT &result); template <typename ResultT> inline v8::Local<v8::Value> render(const ResultT &result);
template <> v8::Local<v8::Value> inline render(const std::string &result) template <> v8::Local<v8::Value> inline render(const std::string &result)
@@ -58,21 +49,11 @@ template <> v8::Local<v8::Value> inline render(const std::string &result)
return Nan::CopyBuffer(result.data(), result.size()).ToLocalChecked(); return Nan::CopyBuffer(result.data(), result.size()).ToLocalChecked();
} }
template <> v8::Local<v8::Value> inline render(const ObjectOrString &result) template <> v8::Local<v8::Value> inline render(const osrm::json::Object &result)
{ {
if (result.is<osrm::json::Object>()) v8::Local<v8::Value> value;
{ renderToV8(value, result);
// Convert osrm::json object tree into matching v8 object tree return value;
v8::Local<v8::Value> value;
renderToV8(value, result.get<osrm::json::Object>());
return value;
}
else
{
// Return the string object as a node Buffer
return Nan::CopyBuffer(result.get<std::string>().data(), result.get<std::string>().size())
.ToLocalChecked();
}
} }
inline void ParseResult(const osrm::Status &result_status, osrm::json::Object &result) inline void ParseResult(const osrm::Status &result_status, osrm::json::Object &result)
@@ -142,10 +123,6 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
if (shared_memory.IsEmpty()) if (shared_memory.IsEmpty())
return engine_config_ptr(); return engine_config_ptr();
auto mmap_memory = params->Get(Nan::New("mmap_memory").ToLocalChecked());
if (mmap_memory.IsEmpty())
return engine_config_ptr();
if (!memory_file->IsUndefined()) if (!memory_file->IsUndefined())
{ {
if (path->IsUndefined()) if (path->IsUndefined())
@@ -194,18 +171,6 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
return engine_config_ptr(); return engine_config_ptr();
} }
} }
if (!mmap_memory->IsUndefined())
{
if (mmap_memory->IsBoolean())
{
engine_config->use_mmap = Nan::To<bool>(mmap_memory).FromJust();
}
else
{
Nan::ThrowError("mmap_memory option must be a boolean");
return engine_config_ptr();
}
}
if (path->IsUndefined() && !engine_config->use_shared_memory) if (path->IsUndefined() && !engine_config->use_shared_memory)
{ {
@@ -692,80 +657,6 @@ 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;
} }
@@ -923,50 +814,6 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
return true; return true;
} }
inline PluginParameters
argumentsToPluginParameters(const Nan::FunctionCallbackInfo<v8::Value> &args)
{
if (args.Length() < 3 || !args[1]->IsObject())
{
return {};
}
v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[1]).ToLocalChecked();
if (obj->Has(Nan::New("format").ToLocalChecked()))
{
v8::Local<v8::Value> format = obj->Get(Nan::New("format").ToLocalChecked());
if (format.IsEmpty())
{
return {};
}
if (!format->IsString())
{
Nan::ThrowError("format must be a string: \"object\" or \"json_buffer\"");
return {};
}
const Nan::Utf8String format_utf8str(format);
std::string format_str{*format_utf8str, *format_utf8str + format_utf8str.length()};
if (format_str == "object")
{
return {false};
}
else if (format_str == "json_buffer")
{
return {true};
}
else
{
Nan::ThrowError("format must be a string: \"object\" or \"json_buffer\"");
return {};
}
}
return {};
}
inline route_parameters_ptr inline route_parameters_ptr
argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args, argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
bool requires_multiple_coordinates) bool requires_multiple_coordinates)
@@ -1257,70 +1104,6 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
} }
if (obj->Has(Nan::New("fallback_speed").ToLocalChecked()))
{
auto fallback_speed = obj->Get(Nan::New("fallback_speed").ToLocalChecked());
if (!fallback_speed->IsNumber())
{
Nan::ThrowError("fallback_speed must be a number");
return table_parameters_ptr();
}
else if (fallback_speed->NumberValue() <= 0)
{
Nan::ThrowError("fallback_speed must be > 0");
return table_parameters_ptr();
}
params->fallback_speed = static_cast<double>(fallback_speed->NumberValue());
}
if (obj->Has(Nan::New("fallback_coordinate").ToLocalChecked()))
{
auto fallback_coordinate = obj->Get(Nan::New("fallback_coordinate").ToLocalChecked());
if (!fallback_coordinate->IsString())
{
Nan::ThrowError("fallback_coordinate must be a string: [input, snapped]");
return table_parameters_ptr();
}
std::string fallback_coordinate_str = *v8::String::Utf8Value(fallback_coordinate);
if (fallback_coordinate_str == "snapped")
{
params->fallback_coordinate_type =
osrm::TableParameters::FallbackCoordinateType::Snapped;
}
else if (fallback_coordinate_str == "input")
{
params->fallback_coordinate_type = osrm::TableParameters::FallbackCoordinateType::Input;
}
else
{
Nan::ThrowError("'fallback_coordinate' param must be one of [input, snapped]");
return table_parameters_ptr();
}
}
if (obj->Has(Nan::New("scale_factor").ToLocalChecked()))
{
auto scale_factor = obj->Get(Nan::New("scale_factor").ToLocalChecked());
if (!scale_factor->IsNumber())
{
Nan::ThrowError("scale_factor must be a number");
return table_parameters_ptr();
}
else if (scale_factor->NumberValue() <= 0)
{
Nan::ThrowError("scale_factor must be > 0");
return table_parameters_ptr();
}
params->scale_factor = static_cast<double>(scale_factor->NumberValue());
}
return params; return params;
} }
@@ -1574,6 +1357,6 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return params; return params;
} }
} // namespace node_osrm } // ns node_osrm
#endif #endif
+14 -33
View File
@@ -75,35 +75,28 @@ template <storage::Ownership Ownership> class CellStorageImpl
// Implementation of the cell view. We need a template parameter here // Implementation of the cell view. We need a template parameter here
// because we need to derive a read-only and read-write view from this. // because we need to derive a read-only and read-write view from this.
template <typename WeightValueT, typename DurationValueT, typename DistanceValueT> template <typename WeightValueT, typename DurationValueT> class CellImpl
class CellImpl
{ {
private: private:
using WeightPtrT = WeightValueT *; using WeightPtrT = WeightValueT *;
using DurationPtrT = DurationValueT *; using DurationPtrT = DurationValueT *;
using DistancePtrT = DistanceValueT *;
BoundarySize num_source_nodes; BoundarySize num_source_nodes;
BoundarySize num_destination_nodes; BoundarySize num_destination_nodes;
WeightPtrT const weights; WeightPtrT const weights;
DurationPtrT const durations; DurationPtrT const durations;
DistancePtrT const distances;
const NodeID *const source_boundary; const NodeID *const source_boundary;
const NodeID *const destination_boundary; const NodeID *const destination_boundary;
using RowIterator = WeightPtrT; using RowIterator = WeightPtrT;
// Possibly replace with // Possibly replace with
// http://www.boost.org/doc/libs/1_55_0/libs/range/doc/html/range/reference/adaptors/reference/strided.html // http://www.boost.org/doc/libs/1_55_0/libs/range/doc/html/range/reference/adaptors/reference/strided.html
class ColumnIterator : public boost::iterator_facade<ColumnIterator,
template <typename ValuePtrT> WeightValueT,
class ColumnIterator : public boost::iterator_facade<ColumnIterator<ValuePtrT>,
decltype(*std::declval<ValuePtrT>()),
boost::random_access_traversal_tag> boost::random_access_traversal_tag>
{ {
typedef boost::iterator_facade<ColumnIterator,
using ValueT = decltype(*std::declval<ValuePtrT>()); WeightValueT,
typedef boost::iterator_facade<ColumnIterator<ValueT>,
ValueT,
boost::random_access_traversal_tag> boost::random_access_traversal_tag>
base_t; base_t;
@@ -115,7 +108,7 @@ template <storage::Ownership Ownership> class CellStorageImpl
explicit ColumnIterator() : current(nullptr), stride(1) {} explicit ColumnIterator() : current(nullptr), stride(1) {}
explicit ColumnIterator(ValuePtrT begin, std::size_t row_length) explicit ColumnIterator(WeightPtrT begin, std::size_t row_length)
: current(begin), stride(row_length) : current(begin), stride(row_length)
{ {
BOOST_ASSERT(begin != nullptr); BOOST_ASSERT(begin != nullptr);
@@ -133,7 +126,7 @@ template <storage::Ownership Ownership> class CellStorageImpl
} }
friend class ::boost::iterator_core_access; friend class ::boost::iterator_core_access;
ValuePtrT current; WeightPtrT current;
const std::size_t stride; const std::size_t stride;
}; };
@@ -154,13 +147,12 @@ template <storage::Ownership Ownership> class CellStorageImpl
auto iter = auto iter =
std::find(destination_boundary, destination_boundary + num_destination_nodes, node); std::find(destination_boundary, destination_boundary + num_destination_nodes, node);
if (iter == destination_boundary + num_destination_nodes) if (iter == destination_boundary + num_destination_nodes)
return boost::make_iterator_range(ColumnIterator<ValuePtr>{}, return boost::make_iterator_range(ColumnIterator{}, ColumnIterator{});
ColumnIterator<ValuePtr>{});
auto column = std::distance(destination_boundary, iter); auto column = std::distance(destination_boundary, iter);
auto begin = ColumnIterator<ValuePtr>{ptr + column, num_destination_nodes}; auto begin = ColumnIterator{ptr + column, num_destination_nodes};
auto end = ColumnIterator<ValuePtr>{ auto end = ColumnIterator{ptr + column + num_source_nodes * num_destination_nodes,
ptr + column + num_source_nodes * num_destination_nodes, num_destination_nodes}; num_destination_nodes};
return boost::make_iterator_range(begin, end); return boost::make_iterator_range(begin, end);
} }
@@ -173,10 +165,6 @@ template <storage::Ownership Ownership> class CellStorageImpl
auto GetInDuration(NodeID node) const { return GetInRange(durations, node); } auto GetInDuration(NodeID node) const { return GetInRange(durations, node); }
auto GetInDistance(NodeID node) const { return GetInRange(distances, node); }
auto GetOutDistance(NodeID node) const { return GetOutRange(distances, node); }
auto GetSourceNodes() const auto GetSourceNodes() const
{ {
return boost::make_iterator_range(source_boundary, source_boundary + num_source_nodes); return boost::make_iterator_range(source_boundary, source_boundary + num_source_nodes);
@@ -191,20 +179,17 @@ template <storage::Ownership Ownership> class CellStorageImpl
CellImpl(const CellData &data, CellImpl(const CellData &data,
WeightPtrT const all_weights, WeightPtrT const all_weights,
DurationPtrT const all_durations, DurationPtrT const all_durations,
DistancePtrT const all_distances,
const NodeID *const all_sources, const NodeID *const all_sources,
const NodeID *const all_destinations) const NodeID *const all_destinations)
: num_source_nodes{data.num_source_nodes}, : num_source_nodes{data.num_source_nodes},
num_destination_nodes{data.num_destination_nodes}, num_destination_nodes{data.num_destination_nodes},
weights{all_weights + data.value_offset}, weights{all_weights + data.value_offset},
durations{all_durations + data.value_offset}, durations{all_durations + data.value_offset},
distances{all_distances + data.value_offset},
source_boundary{all_sources + data.source_boundary_offset}, source_boundary{all_sources + data.source_boundary_offset},
destination_boundary{all_destinations + data.destination_boundary_offset} destination_boundary{all_destinations + data.destination_boundary_offset}
{ {
BOOST_ASSERT(all_weights != nullptr); BOOST_ASSERT(all_weights != nullptr);
BOOST_ASSERT(all_durations != nullptr); BOOST_ASSERT(all_durations != nullptr);
BOOST_ASSERT(all_distances != nullptr);
BOOST_ASSERT(num_source_nodes == 0 || all_sources != nullptr); BOOST_ASSERT(num_source_nodes == 0 || all_sources != nullptr);
BOOST_ASSERT(num_destination_nodes == 0 || all_destinations != nullptr); BOOST_ASSERT(num_destination_nodes == 0 || all_destinations != nullptr);
} }
@@ -216,8 +201,7 @@ template <storage::Ownership Ownership> class CellStorageImpl
const NodeID *const all_destinations) const NodeID *const all_destinations)
: num_source_nodes{data.num_source_nodes}, : num_source_nodes{data.num_source_nodes},
num_destination_nodes{data.num_destination_nodes}, weights{nullptr}, num_destination_nodes{data.num_destination_nodes}, weights{nullptr},
durations{nullptr}, distances{nullptr}, durations{nullptr}, source_boundary{all_sources + data.source_boundary_offset},
source_boundary{all_sources + data.source_boundary_offset},
destination_boundary{all_destinations + data.destination_boundary_offset} destination_boundary{all_destinations + data.destination_boundary_offset}
{ {
BOOST_ASSERT(num_source_nodes == 0 || all_sources != nullptr); BOOST_ASSERT(num_source_nodes == 0 || all_sources != nullptr);
@@ -228,8 +212,8 @@ template <storage::Ownership Ownership> class CellStorageImpl
std::size_t LevelIDToIndex(LevelID level) const { return level - 1; } std::size_t LevelIDToIndex(LevelID level) const { return level - 1; }
public: public:
using Cell = CellImpl<EdgeWeight, EdgeDuration, EdgeDistance>; using Cell = CellImpl<EdgeWeight, EdgeDuration>;
using ConstCell = CellImpl<const EdgeWeight, const EdgeDuration, const EdgeDistance>; using ConstCell = CellImpl<const EdgeWeight, const EdgeDuration>;
CellStorageImpl() {} CellStorageImpl() {}
@@ -377,7 +361,6 @@ template <storage::Ownership Ownership> class CellStorageImpl
metric.weights.resize(total_size + 1, INVALID_EDGE_WEIGHT); metric.weights.resize(total_size + 1, INVALID_EDGE_WEIGHT);
metric.durations.resize(total_size + 1, MAXIMAL_EDGE_DURATION); metric.durations.resize(total_size + 1, MAXIMAL_EDGE_DURATION);
metric.distances.resize(total_size + 1, INVALID_EDGE_DISTANCE);
return metric; return metric;
} }
@@ -405,7 +388,6 @@ template <storage::Ownership Ownership> class CellStorageImpl
return ConstCell{cells[cell_index], return ConstCell{cells[cell_index],
metric.weights.data(), metric.weights.data(),
metric.durations.data(), metric.durations.data(),
metric.distances.data(),
source_boundary.empty() ? nullptr : source_boundary.data(), source_boundary.empty() ? nullptr : source_boundary.data(),
destination_boundary.empty() ? nullptr : destination_boundary.data()}; destination_boundary.empty() ? nullptr : destination_boundary.data()};
} }
@@ -433,7 +415,6 @@ template <storage::Ownership Ownership> class CellStorageImpl
return Cell{cells[cell_index], return Cell{cells[cell_index],
metric.weights.data(), metric.weights.data(),
metric.durations.data(), metric.durations.data(),
metric.distances.data(),
source_boundary.data(), source_boundary.data(),
destination_boundary.data()}; destination_boundary.data()};
} }
@@ -43,7 +43,6 @@ splitBidirectionalEdges(const std::vector<extractor::EdgeBasedEdge> &edges)
edge.data.turn_id, edge.data.turn_id,
std::max(edge.data.weight, 1), std::max(edge.data.weight, 1),
edge.data.duration, edge.data.duration,
edge.data.distance,
edge.data.forward, edge.data.forward,
edge.data.backward); edge.data.backward);
@@ -52,7 +51,6 @@ splitBidirectionalEdges(const std::vector<extractor::EdgeBasedEdge> &edges)
edge.data.turn_id, edge.data.turn_id,
std::max(edge.data.weight, 1), std::max(edge.data.weight, 1),
edge.data.duration, edge.data.duration,
edge.data.distance,
edge.data.backward, edge.data.backward,
edge.data.forward); edge.data.forward);
} }
+2 -25
View File
@@ -135,16 +135,6 @@ 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];
@@ -172,13 +162,6 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
(-approach_type % (-approach_type %
';')[ph::bind(&engine::api::BaseParameters::approaches, qi::_r1) = qi::_1]; ';')[ph::bind(&engine::api::BaseParameters::approaches, qi::_r1) = qi::_1];
snapping_type.add("default", engine::api::BaseParameters::SnappingType::Default)(
"any", engine::api::BaseParameters::SnappingType::Any);
snapping_rule =
qi::lit("snapping=") >
snapping_type[ph::bind(&engine::api::BaseParameters::snapping, qi::_r1) = qi::_1];
exclude_rule = qi::lit("exclude=") > exclude_rule = qi::lit("exclude=") >
(qi::as_string[+qi::char_("a-zA-Z0-9")] % (qi::as_string[+qi::char_("a-zA-Z0-9")] %
',')[ph::bind(&engine::api::BaseParameters::exclude, qi::_r1) = qi::_1]; ',')[ph::bind(&engine::api::BaseParameters::exclude, qi::_r1) = qi::_1];
@@ -188,17 +171,13 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
| bearings_rule(qi::_r1) // | bearings_rule(qi::_r1) //
| 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) //
| stoppage_rule(qi::_r1); //
} }
protected: protected:
qi::rule<Iterator, Signature> base_rule; qi::rule<Iterator, Signature> base_rule;
qi::rule<Iterator, Signature> query_rule; qi::rule<Iterator, Signature> query_rule;
qi::real_parser<double, json_policy> double_;
private: private:
qi::rule<Iterator, Signature> bearings_rule; qi::rule<Iterator, Signature> bearings_rule;
qi::rule<Iterator, Signature> radiuses_rule; qi::rule<Iterator, Signature> radiuses_rule;
@@ -207,7 +186,6 @@ 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;
@@ -217,10 +195,9 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
qi::rule<Iterator, unsigned char()> base64_char; qi::rule<Iterator, unsigned char()> base64_char;
qi::rule<Iterator, std::string()> polyline_chars; qi::rule<Iterator, std::string()> polyline_chars;
qi::rule<Iterator, double()> unlimited_rule; qi::rule<Iterator, double()> unlimited_rule;
qi::rule<Iterator, Signature> snapping_rule; qi::real_parser<double, json_policy> double_;
qi::symbols<char, engine::Approach> approach_type; qi::symbols<char, engine::Approach> approach_type;
qi::symbols<char, engine::api::BaseParameters::SnappingType> snapping_type;
}; };
} }
} }
+5 -30
View File
@@ -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 &)>
@@ -48,28 +48,10 @@ struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature
(qi::lit("all") | (qi::lit("all") |
(size_t_ % ';')[ph::bind(&engine::api::TableParameters::sources, qi::_r1) = qi::_1]); (size_t_ % ';')[ph::bind(&engine::api::TableParameters::sources, qi::_r1) = qi::_1]);
fallback_speed_rule =
qi::lit("fallback_speed=") >
(double_)[ph::bind(&engine::api::TableParameters::fallback_speed, qi::_r1) = qi::_1];
fallback_coordinate_type.add("input",
engine::api::TableParameters::FallbackCoordinateType::Input)(
"snapped", engine::api::TableParameters::FallbackCoordinateType::Snapped);
scale_factor_rule =
qi::lit("scale_factor=") >
(double_)[ph::bind(&engine::api::TableParameters::scale_factor, qi::_r1) = qi::_1];
table_rule = destinations_rule(qi::_r1) | sources_rule(qi::_r1); table_rule = destinations_rule(qi::_r1) | sources_rule(qi::_r1);
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") > root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
-('?' > (table_rule(qi::_r1) | base_rule(qi::_r1) | scale_factor_rule(qi::_r1) | -('?' > (table_rule(qi::_r1) | base_rule(qi::_r1)) % '&');
fallback_speed_rule(qi::_r1) |
(qi::lit("fallback_coordinate=") >
fallback_coordinate_type
[ph::bind(&engine::api::TableParameters::fallback_coordinate_type,
qi::_r1) = qi::_1])) %
'&');
} }
TableParametersGrammar(qi::rule<Iterator, Signature> &root_rule_) : BaseGrammar(root_rule_) TableParametersGrammar(qi::rule<Iterator, Signature> &root_rule_) : BaseGrammar(root_rule_)
@@ -91,23 +73,16 @@ struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature
qi::rule<Iterator, Signature> base_rule; qi::rule<Iterator, Signature> base_rule;
private: private:
using json_policy = no_trailing_dot_policy<double, 'j', 's', 'o', 'n'>;
qi::rule<Iterator, Signature> root_rule; qi::rule<Iterator, Signature> root_rule;
qi::rule<Iterator, Signature> table_rule; qi::rule<Iterator, Signature> table_rule;
qi::rule<Iterator, Signature> sources_rule; qi::rule<Iterator, Signature> sources_rule;
qi::rule<Iterator, Signature> destinations_rule; qi::rule<Iterator, Signature> destinations_rule;
qi::rule<Iterator, Signature> fallback_speed_rule;
qi::rule<Iterator, Signature> scale_factor_rule;
qi::rule<Iterator, std::size_t()> size_t_; qi::rule<Iterator, std::size_t()> size_t_;
qi::symbols<char, engine::api::TableParameters::AnnotationsType> annotations; qi::symbols<char, engine::api::TableParameters::AnnotationsType> annotations;
qi::rule<Iterator, engine::api::TableParameters::AnnotationsType()> annotations_list; qi::rule<Iterator, engine::api::TableParameters::AnnotationsType()> annotations_list;
qi::symbols<char, engine::api::TableParameters::FallbackCoordinateType>
fallback_coordinate_type;
qi::real_parser<double, json_policy> double_;
}; };
} // namespace api }
} // namespace server }
} // namespace osrm }
#endif #endif
+3 -8
View File
@@ -16,15 +16,10 @@ struct Block
{ {
std::uint64_t num_entries; std::uint64_t num_entries;
std::uint64_t byte_size; std::uint64_t byte_size;
std::uint64_t offset;
Block() : num_entries(0), byte_size(0), offset(0) {} Block() : num_entries(0), byte_size(0) {}
Block(std::uint64_t num_entries, std::uint64_t byte_size, std::uint64_t offset)
: num_entries(num_entries), byte_size(byte_size), offset(offset)
{
}
Block(std::uint64_t num_entries, std::uint64_t byte_size) Block(std::uint64_t num_entries, std::uint64_t byte_size)
: num_entries(num_entries), byte_size(byte_size), offset(0) : num_entries(num_entries), byte_size(byte_size)
{ {
} }
}; };
@@ -34,7 +29,7 @@ using NamedBlock = std::tuple<std::string, Block>;
template <typename T> Block make_block(uint64_t num_entries) template <typename T> Block make_block(uint64_t num_entries)
{ {
static_assert(sizeof(T) % alignof(T) == 0, "aligned T* can't be used as an array pointer"); static_assert(sizeof(T) % alignof(T) == 0, "aligned T* can't be used as an array pointer");
return Block{num_entries, sizeof(T) * num_entries, 0}; return Block{num_entries, sizeof(T) * num_entries};
} }
} }
} }
+22 -40
View File
@@ -9,7 +9,6 @@
#include "storage/shared_datatype.hpp" #include "storage/shared_datatype.hpp"
#include "storage/tar.hpp" #include "storage/tar.hpp"
#include <boost/assert.hpp>
#include <boost/function_output_iterator.hpp> #include <boost/function_output_iterator.hpp>
#include <boost/iterator/function_input_iterator.hpp> #include <boost/iterator/function_input_iterator.hpp>
@@ -31,37 +30,22 @@ namespace serialization
namespace detail namespace detail
{ {
template <typename T, typename BlockT = unsigned char> template <typename T, typename BlockT = unsigned char>
inline BlockT packBits(const T &data, std::size_t base_index, const std::size_t count) inline BlockT packBits(const T &data, std::size_t index, std::size_t count)
{ {
static_assert(std::is_same<typename T::value_type, bool>::value, "value_type is not bool"); static_assert(std::is_same<typename T::value_type, bool>::value, "value_type is not bool");
static_assert(std::is_unsigned<BlockT>::value, "BlockT must be unsigned type");
static_assert(std::is_integral<BlockT>::value, "BlockT must be an integral type");
static_assert(CHAR_BIT == 8, "Non-8-bit bytes not supported, sorry!");
BOOST_ASSERT(sizeof(BlockT) * CHAR_BIT >= count);
// Note: if this packing is changed, be sure to update vector_view<bool>
// as well, so that on-disk and in-memory layouts match.
BlockT value = 0; BlockT value = 0;
for (std::size_t bit = 0; bit < count; ++bit) for (std::size_t bit = 0; bit < count; ++bit, ++index)
{ value = (value << 1) | data[index];
value |= (data[base_index + bit] ? BlockT{1} : BlockT{0}) << bit;
}
return value; return value;
} }
template <typename T, typename BlockT = unsigned char> template <typename T, typename BlockT = unsigned char>
inline void inline void unpackBits(T &data, std::size_t index, std::size_t count, BlockT value)
unpackBits(T &data, const std::size_t base_index, const std::size_t count, const BlockT value)
{ {
static_assert(std::is_same<typename T::value_type, bool>::value, "value_type is not bool"); static_assert(std::is_same<typename T::value_type, bool>::value, "value_type is not bool");
static_assert(std::is_unsigned<BlockT>::value, "BlockT must be unsigned type"); const BlockT mask = BlockT{1} << (count - 1);
static_assert(std::is_integral<BlockT>::value, "BlockT must be an integral type"); for (std::size_t bit = 0; bit < count; value <<= 1, ++bit, ++index)
static_assert(CHAR_BIT == 8, "Non-8-bit bytes not supported, sorry!"); data[index] = value & mask;
BOOST_ASSERT(sizeof(BlockT) * CHAR_BIT >= count);
for (std::size_t bit = 0; bit < count; ++bit)
{
data[base_index + bit] = value & (BlockT{1} << bit);
}
} }
template <typename VectorT> template <typename VectorT>
@@ -71,16 +55,15 @@ void readBoolVector(tar::FileReader &reader, const std::string &name, VectorT &d
data.resize(count); data.resize(count);
std::uint64_t index = 0; std::uint64_t index = 0;
using BlockType = std::uint64_t; constexpr std::uint64_t WORD_BITS = CHAR_BIT * sizeof(std::uint64_t);
constexpr std::uint64_t BLOCK_BITS = CHAR_BIT * sizeof(BlockType);
const auto decode = [&](const BlockType block) { const auto decode = [&](const std::uint64_t block) {
auto read_size = std::min<std::size_t>(count - index, BLOCK_BITS); auto read_size = std::min<std::size_t>(count - index, WORD_BITS);
unpackBits<VectorT, BlockType>(data, index, read_size, block); unpackBits<VectorT, std::uint64_t>(data, index, read_size, block);
index += BLOCK_BITS; index += WORD_BITS;
}; };
reader.ReadStreaming<BlockType>(name, boost::make_function_output_iterator(decode)); reader.ReadStreaming<std::uint64_t>(name, boost::make_function_output_iterator(decode));
} }
template <typename VectorT> template <typename VectorT>
@@ -90,20 +73,19 @@ void writeBoolVector(tar::FileWriter &writer, const std::string &name, const Vec
writer.WriteElementCount64(name, count); writer.WriteElementCount64(name, count);
std::uint64_t index = 0; std::uint64_t index = 0;
using BlockType = std::uint64_t; constexpr std::uint64_t WORD_BITS = CHAR_BIT * sizeof(std::uint64_t);
constexpr std::uint64_t BLOCK_BITS = CHAR_BIT * sizeof(BlockType);
// FIXME on old boost version the function_input_iterator does not work with lambdas // FIXME on old boost version the function_input_iterator does not work with lambdas
// so we need to wrap it in a function here. // so we need to wrap it in a function here.
const std::function<BlockType()> encode_function = [&]() -> BlockType { const std::function<std::uint64_t()> encode_function = [&]() -> std::uint64_t {
auto write_size = std::min<std::size_t>(count - index, BLOCK_BITS); auto write_size = std::min<std::size_t>(count - index, WORD_BITS);
auto packed = packBits<VectorT, BlockType>(data, index, write_size); auto packed = packBits<VectorT, std::uint64_t>(data, index, write_size);
index += BLOCK_BITS; index += WORD_BITS;
return packed; return packed;
}; };
std::uint64_t number_of_blocks = (count + BLOCK_BITS - 1) / BLOCK_BITS; std::uint64_t number_of_blocks = (count + WORD_BITS - 1) / WORD_BITS;
writer.WriteStreaming<BlockType>( writer.WriteStreaming<std::uint64_t>(
name, name,
boost::make_function_input_iterator(encode_function, boost::infinite()), boost::make_function_input_iterator(encode_function, boost::infinite()),
number_of_blocks); number_of_blocks);
@@ -284,9 +266,9 @@ template <typename K, typename V> void write(io::BufferWriter &writer, const std
} }
} }
inline void read(io::BufferReader &reader, BaseDataLayout &layout) { read(reader, layout.blocks); } inline void read(io::BufferReader &reader, DataLayout &layout) { read(reader, layout.blocks); }
inline void write(io::BufferWriter &writer, const BaseDataLayout &layout) inline void write(io::BufferWriter &writer, const DataLayout &layout)
{ {
write(writer, layout.blocks); write(writer, layout.blocks);
} }
+11 -24
View File
@@ -5,7 +5,6 @@
#include <boost/function_output_iterator.hpp> #include <boost/function_output_iterator.hpp>
#include <type_traits>
#include <unordered_map> #include <unordered_map>
namespace osrm namespace osrm
@@ -20,8 +19,8 @@ class SharedDataIndex
public: public:
struct AllocatedRegion struct AllocatedRegion
{ {
void *memory_ptr; char *memory_ptr;
std::unique_ptr<BaseDataLayout> layout; DataLayout layout;
}; };
SharedDataIndex() = default; SharedDataIndex() = default;
@@ -30,10 +29,10 @@ class SharedDataIndex
// Build mapping from block name to region // Build mapping from block name to region
for (auto index : util::irange<std::uint32_t>(0, regions.size())) for (auto index : util::irange<std::uint32_t>(0, regions.size()))
{ {
regions[index].layout->List("", regions[index].layout.List("",
boost::make_function_output_iterator([&](const auto &name) { boost::make_function_output_iterator([&](const auto &name) {
block_to_region[name] = index; block_to_region[name] = index;
})); }));
} }
} }
@@ -41,44 +40,32 @@ class SharedDataIndex
{ {
for (const auto &region : regions) for (const auto &region : regions)
{ {
region.layout->List(name_prefix, out); region.layout.List(name_prefix, out);
} }
} }
template <typename T> auto GetBlockPtr(const std::string &name) const template <typename T> auto GetBlockPtr(const std::string &name) const
{ {
#if !defined(__GNUC__) || (__GNUC__ > 4)
// is_tivially_copyable only exists in GCC >=5
static_assert(std::is_trivially_copyable<T>::value,
"Block-based data must be a trivially copyable type");
static_assert(sizeof(T) % alignof(T) == 0, "aligned T* can't be used as an array pointer");
#endif
const auto &region = GetBlockRegion(name); const auto &region = GetBlockRegion(name);
return reinterpret_cast<T *>(region.layout->GetBlockPtr(region.memory_ptr, name)); return region.layout.GetBlockPtr<T>(region.memory_ptr, name);
} }
template <typename T> auto GetBlockPtr(const std::string &name) template <typename T> auto GetBlockPtr(const std::string &name)
{ {
#if !defined(__GNUC__) || (__GNUC__ > 4)
// is_tivially_copyable only exists in GCC >=5
static_assert(std::is_trivially_copyable<T>::value,
"Block-based data must be a trivially copyable type");
static_assert(sizeof(T) % alignof(T) == 0, "aligned T* can't be used as an array pointer");
#endif
const auto &region = GetBlockRegion(name); const auto &region = GetBlockRegion(name);
return reinterpret_cast<T *>(region.layout->GetBlockPtr(region.memory_ptr, name)); return region.layout.GetBlockPtr<T>(region.memory_ptr, name);
} }
std::size_t GetBlockEntries(const std::string &name) const std::size_t GetBlockEntries(const std::string &name) const
{ {
const auto &region = GetBlockRegion(name); const auto &region = GetBlockRegion(name);
return region.layout->GetBlockEntries(name); return region.layout.GetBlockEntries(name);
} }
std::size_t GetBlockSize(const std::string &name) const std::size_t GetBlockSize(const std::string &name) const
{ {
const auto &region = GetBlockRegion(name); const auto &region = GetBlockRegion(name);
return region.layout->GetBlockSize(name); return region.layout.GetBlockSize(name);
} }
private: private:
+41 -76
View File
@@ -20,13 +20,13 @@ namespace osrm
namespace storage namespace storage
{ {
class BaseDataLayout; class DataLayout;
namespace serialization namespace serialization
{ {
inline void read(io::BufferReader &reader, BaseDataLayout &layout); inline void read(io::BufferReader &reader, DataLayout &layout);
inline void write(io::BufferWriter &writer, const BaseDataLayout &layout); inline void write(io::BufferWriter &writer, const DataLayout &layout);
} // namespace serialization }
namespace detail namespace detail
{ {
@@ -52,30 +52,46 @@ inline std::string trimName(const std::string &name_prefix, const std::string &n
return name; return name;
} }
} }
} // namespace detail }
class BaseDataLayout class DataLayout
{ {
public: public:
virtual ~BaseDataLayout() = default; DataLayout() : blocks{} {}
inline void SetBlock(const std::string &name, Block block) { blocks[name] = std::move(block); } inline void SetBlock(const std::string &name, Block block) { blocks[name] = std::move(block); }
inline std::uint64_t GetBlockEntries(const std::string &name) const inline uint64_t GetBlockEntries(const std::string &name) const
{ {
return GetBlock(name).num_entries; return GetBlock(name).num_entries;
} }
inline std::uint64_t GetBlockSize(const std::string &name) const inline uint64_t GetBlockSize(const std::string &name) const { return GetBlock(name).byte_size; }
{
return GetBlock(name).byte_size;
}
inline bool HasBlock(const std::string &name) const inline bool HasBlock(const std::string &name) const
{ {
return blocks.find(name) != blocks.end(); return blocks.find(name) != blocks.end();
} }
inline uint64_t GetSizeOfLayout() const
{
uint64_t result = 0;
for (const auto &name_and_block : blocks)
{
result += GetBlockSize(name_and_block.first) + BLOCK_ALIGNMENT;
}
return result;
}
template <typename T> inline T *GetBlockPtr(char *shared_memory, const std::string &name) const
{
static_assert(BLOCK_ALIGNMENT % std::alignment_of<T>::value == 0,
"Datatype does not fit alignment constraints.");
char *ptr = (char *)GetAlignedBlockPtr(shared_memory, name);
return (T *)ptr;
}
// Depending on the name prefix this function either lists all blocks with the same prefix // Depending on the name prefix this function either lists all blocks with the same prefix
// or all entries in the sub-directory. // or all entries in the sub-directory.
// '/ch/edge' -> '/ch/edge_filter/0/blocks', '/ch/edge_filter/1/blocks' // '/ch/edge' -> '/ch/edge_filter/0/blocks', '/ch/edge_filter/1/blocks'
@@ -99,10 +115,10 @@ class BaseDataLayout
} }
} }
virtual inline void *GetBlockPtr(void *base_ptr, const std::string &name) const = 0; private:
virtual inline std::uint64_t GetSizeOfLayout() const = 0; friend void serialization::read(io::BufferReader &reader, DataLayout &layout);
friend void serialization::write(io::BufferWriter &writer, const DataLayout &layout);
protected:
const Block &GetBlock(const std::string &name) const const Block &GetBlock(const std::string &name) const
{ {
auto iter = blocks.find(name); auto iter = blocks.find(name);
@@ -114,42 +130,10 @@ class BaseDataLayout
return iter->second; return iter->second;
} }
friend void serialization::read(io::BufferReader &reader, BaseDataLayout &layout);
friend void serialization::write(io::BufferWriter &writer, const BaseDataLayout &layout);
std::map<std::string, Block> blocks;
};
class ContiguousDataLayout final : public BaseDataLayout
{
public:
inline std::uint64_t GetSizeOfLayout() const override final
{
std::uint64_t result = 0;
for (const auto &name_and_block : blocks)
{
result += GetBlockSize(name_and_block.first) + BLOCK_ALIGNMENT;
}
return result;
}
inline void *GetBlockPtr(void *base_ptr, const std::string &name) const override final
{
// TODO: re-enable this alignment checking somehow
// static_assert(BLOCK_ALIGNMENT % std::alignment_of<T>::value == 0,
// "Datatype does not fit alignment constraints.");
return GetAlignedBlockPtr(base_ptr, name);
}
private:
friend void serialization::read(io::BufferReader &reader, BaseDataLayout &layout);
friend void serialization::write(io::BufferWriter &writer, const BaseDataLayout &layout);
// Fit aligned storage in buffer to 64 bytes to conform with AVX 512 types // Fit aligned storage in buffer to 64 bytes to conform with AVX 512 types
inline void *align(void *&ptr) const noexcept inline void *align(void *&ptr) const noexcept
{ {
const auto intptr = reinterpret_cast<std::uintptr_t>(ptr); const auto intptr = reinterpret_cast<uintptr_t>(ptr);
const auto aligned = (intptr - 1u + BLOCK_ALIGNMENT) & -BLOCK_ALIGNMENT; const auto aligned = (intptr - 1u + BLOCK_ALIGNMENT) & -BLOCK_ALIGNMENT;
return ptr = reinterpret_cast<void *>(aligned); return ptr = reinterpret_cast<void *>(aligned);
} }
@@ -173,27 +157,7 @@ class ContiguousDataLayout final : public BaseDataLayout
} }
static constexpr std::size_t BLOCK_ALIGNMENT = 64; static constexpr std::size_t BLOCK_ALIGNMENT = 64;
}; std::map<std::string, Block> blocks;
class TarDataLayout final : public BaseDataLayout
{
public:
inline std::uint64_t GetSizeOfLayout() const override final
{
std::uint64_t result = 0;
for (const auto &name_and_block : blocks)
{
result += GetBlockSize(name_and_block.first);
}
return result;
}
inline void *GetBlockPtr(void *base_ptr, const std::string &name) const override final
{
auto offset = GetBlock(name).offset;
const auto offset_address = reinterpret_cast<std::uintptr_t>(base_ptr) + offset;
return reinterpret_cast<void *>(offset_address);
}
}; };
struct SharedRegion struct SharedRegion
@@ -201,7 +165,7 @@ struct SharedRegion
static constexpr const int MAX_NAME_LENGTH = 254; static constexpr const int MAX_NAME_LENGTH = 254;
SharedRegion() : name{0}, timestamp{0} {} SharedRegion() : name{0}, timestamp{0} {}
SharedRegion(const std::string &name_, std::uint64_t timestamp, std::uint16_t shm_key) SharedRegion(const std::string &name_, std::uint64_t timestamp, std::uint8_t shm_key)
: name{0}, timestamp{timestamp}, shm_key{shm_key} : name{0}, timestamp{timestamp}, shm_key{shm_key}
{ {
std::copy_n(name_.begin(), std::min<std::size_t>(MAX_NAME_LENGTH, name_.size()), name); std::copy_n(name_.begin(), std::min<std::size_t>(MAX_NAME_LENGTH, name_.size()), name);
@@ -211,14 +175,14 @@ struct SharedRegion
char name[MAX_NAME_LENGTH + 1]; char name[MAX_NAME_LENGTH + 1];
std::uint64_t timestamp; std::uint64_t timestamp;
std::uint16_t shm_key; std::uint8_t shm_key;
}; };
// Keeps a list of all shared regions in a fixed-sized struct // Keeps a list of all shared regions in a fixed-sized struct
// for fast access and deserialization. // for fast access and deserialization.
struct SharedRegionRegister struct SharedRegionRegister
{ {
using RegionID = std::uint16_t; using RegionID = std::uint8_t;
static constexpr const RegionID INVALID_REGION_ID = std::numeric_limits<RegionID>::max(); static constexpr const RegionID INVALID_REGION_ID = std::numeric_limits<RegionID>::max();
using ShmKey = decltype(SharedRegion::shm_key); using ShmKey = decltype(SharedRegion::shm_key);
@@ -286,11 +250,12 @@ struct SharedRegionRegister
void ReleaseKey(ShmKey key) { shm_key_in_use[key] = false; } void ReleaseKey(ShmKey key) { shm_key_in_use[key] = false; }
static constexpr const std::size_t MAX_SHARED_REGIONS = 512; static constexpr const std::uint8_t MAX_SHARED_REGIONS =
std::numeric_limits<RegionID>::max() - 1;
static_assert(MAX_SHARED_REGIONS < std::numeric_limits<RegionID>::max(), static_assert(MAX_SHARED_REGIONS < std::numeric_limits<RegionID>::max(),
"Number of shared memory regions needs to be less than the region id size."); "Number of shared memory regions needs to be less than the region id size.");
static constexpr const std::size_t MAX_SHM_KEYS = MAX_SHARED_REGIONS * 2; static constexpr const std::uint8_t MAX_SHM_KEYS = std::numeric_limits<std::uint8_t>::max() - 1;
static constexpr const char *name = "osrm-region"; static constexpr const char *name = "osrm-region";
@@ -298,7 +263,7 @@ struct SharedRegionRegister
std::array<SharedRegion, MAX_SHARED_REGIONS> regions; std::array<SharedRegion, MAX_SHARED_REGIONS> regions;
std::array<bool, MAX_SHM_KEYS> shm_key_in_use; std::array<bool, MAX_SHM_KEYS> shm_key_in_use;
}; };
} // namespace storage }
} // namespace osrm }
#endif /* SHARED_DATA_TYPE_HPP */ #endif /* SHARED_DATA_TYPE_HPP */
+9 -10
View File
@@ -34,10 +34,10 @@ namespace storage
struct OSRMLockFile struct OSRMLockFile
{ {
template <typename IdentifierT> boost::filesystem::path operator()(const IdentifierT &id) boost::filesystem::path operator()()
{ {
boost::filesystem::path temp_dir = boost::filesystem::temp_directory_path(); boost::filesystem::path temp_dir = boost::filesystem::temp_directory_path();
boost::filesystem::path lock_file = temp_dir / ("osrm-" + std::to_string(id) + ".lock"); boost::filesystem::path lock_file = temp_dir / "osrm.lock";
return lock_file; return lock_file;
} }
}; };
@@ -93,7 +93,7 @@ class SharedMemory
try try
{ {
OSRMLockFile lock_file; OSRMLockFile lock_file;
boost::interprocess::xsi_key key(lock_file(id).string().c_str(), id); boost::interprocess::xsi_key key(lock_file().string().c_str(), id);
result = RegionExists(key); result = RegionExists(key);
} }
catch (...) catch (...)
@@ -106,7 +106,7 @@ class SharedMemory
template <typename IdentifierT> static bool Remove(const IdentifierT id) template <typename IdentifierT> static bool Remove(const IdentifierT id)
{ {
OSRMLockFile lock_file; OSRMLockFile lock_file;
boost::interprocess::xsi_key key(lock_file(id).string().c_str(), id); boost::interprocess::xsi_key key(lock_file().string().c_str(), id);
return Remove(key); return Remove(key);
} }
@@ -287,11 +287,10 @@ class SharedMemory
template <typename IdentifierT, typename LockFileT = OSRMLockFile> template <typename IdentifierT, typename LockFileT = OSRMLockFile>
std::unique_ptr<SharedMemory> makeSharedMemory(const IdentifierT &id, const uint64_t size = 0) std::unique_ptr<SharedMemory> makeSharedMemory(const IdentifierT &id, const uint64_t size = 0)
{ {
static_assert(sizeof(id) == sizeof(std::uint16_t), "Key type is not 16 bits");
try try
{ {
LockFileT lock_file; LockFileT lock_file;
if (!boost::filesystem::exists(lock_file(id))) if (!boost::filesystem::exists(lock_file()))
{ {
if (0 == size) if (0 == size)
{ {
@@ -299,10 +298,10 @@ std::unique_ptr<SharedMemory> makeSharedMemory(const IdentifierT &id, const uint
} }
else else
{ {
boost::filesystem::ofstream ofs(lock_file(id)); boost::filesystem::ofstream ofs(lock_file());
} }
} }
return std::make_unique<SharedMemory>(lock_file(id), id, size); return std::make_unique<SharedMemory>(lock_file(), id, size);
} }
catch (const boost::interprocess::interprocess_exception &e) catch (const boost::interprocess::interprocess_exception &e)
{ {
@@ -311,7 +310,7 @@ std::unique_ptr<SharedMemory> makeSharedMemory(const IdentifierT &id, const uint
throw util::exception(e.what() + SOURCE_REF); throw util::exception(e.what() + SOURCE_REF);
} }
} }
} // namespace storage }
} // namespace osrm }
#endif // SHARED_MEMORY_HPP #endif // SHARED_MEMORY_HPP
+4 -6
View File
@@ -33,7 +33,7 @@ template <class Lock> class InvertedLock
InvertedLock(Lock &lock) : lock(lock) { lock.unlock(); } InvertedLock(Lock &lock) : lock(lock) { lock.unlock(); }
~InvertedLock() { lock.lock(); } ~InvertedLock() { lock.lock(); }
}; };
} // namespace }
// The shared monitor implementation based on a semaphore and mutex // The shared monitor implementation based on a semaphore and mutex
template <typename Data> struct SharedMonitor template <typename Data> struct SharedMonitor
@@ -146,9 +146,7 @@ template <typename Data> struct SharedMonitor
// like two-turnstile reusable barrier or boost/interprocess/sync/spin/condition.hpp // like two-turnstile reusable barrier or boost/interprocess/sync/spin/condition.hpp
// fail if a waiter is killed. // fail if a waiter is killed.
// Buffer size needs to be large enough to hold all the semaphores for every static constexpr int buffer_size = 256;
// listener you want to support.
static constexpr int buffer_size = 4096 * 4;
struct InternalData struct InternalData
{ {
@@ -234,8 +232,8 @@ template <typename Data> struct SharedMonitor
bi::shared_memory_object shmem; bi::shared_memory_object shmem;
bi::mapped_region region; bi::mapped_region region;
}; };
} // namespace storage }
} // namespace osrm }
#undef USE_BOOST_INTERPROCESS_CONDITION #undef USE_BOOST_INTERPROCESS_CONDITION
+3 -9
View File
@@ -35,28 +35,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <string> #include <string>
#include <vector>
namespace osrm namespace osrm
{ {
namespace storage namespace storage
{ {
void populateLayoutFromFile(const boost::filesystem::path &path, storage::BaseDataLayout &layout);
class Storage class Storage
{ {
public: public:
Storage(StorageConfig config); Storage(StorageConfig config);
int Run(int max_wait, const std::string &name, bool only_metric); int Run(int max_wait, const std::string &name, bool only_metric);
void PopulateStaticLayout(DataLayout &layout);
void PopulateUpdatableLayout(DataLayout &layout);
void PopulateStaticData(const SharedDataIndex &index); void PopulateStaticData(const SharedDataIndex &index);
void PopulateUpdatableData(const SharedDataIndex &index); void PopulateUpdatableData(const SharedDataIndex &index);
void PopulateLayout(storage::BaseDataLayout &layout,
const std::vector<std::pair<bool, boost::filesystem::path>> &files);
std::string PopulateLayoutWithRTree(storage::BaseDataLayout &layout);
std::vector<std::pair<bool, boost::filesystem::path>> GetUpdatableFiles();
std::vector<std::pair<bool, boost::filesystem::path>> GetStaticFiles();
private: private:
StorageConfig config; StorageConfig config;
+3 -10
View File
@@ -294,14 +294,11 @@ inline auto make_filtered_cell_metric_view(const SharedDataIndex &index,
auto prefix = name + "/exclude/" + std::to_string(exclude_index); auto prefix = name + "/exclude/" + std::to_string(exclude_index);
auto weights_block_id = prefix + "/weights"; auto weights_block_id = prefix + "/weights";
auto durations_block_id = prefix + "/durations"; auto durations_block_id = prefix + "/durations";
auto distances_block_id = prefix + "/distances";
auto weights = make_vector_view<EdgeWeight>(index, weights_block_id); auto weights = make_vector_view<EdgeWeight>(index, weights_block_id);
auto durations = make_vector_view<EdgeDuration>(index, durations_block_id); auto durations = make_vector_view<EdgeDuration>(index, durations_block_id);
auto distances = make_vector_view<EdgeDistance>(index, distances_block_id);
return customizer::CellMetricView{ return customizer::CellMetricView{std::move(weights), std::move(durations)};
std::move(weights), std::move(durations), std::move(distances)};
} }
inline auto make_cell_metric_view(const SharedDataIndex &index, const std::string &name) inline auto make_cell_metric_view(const SharedDataIndex &index, const std::string &name)
@@ -314,14 +311,12 @@ inline auto make_cell_metric_view(const SharedDataIndex &index, const std::strin
{ {
auto weights_block_id = prefix + "/weights"; auto weights_block_id = prefix + "/weights";
auto durations_block_id = prefix + "/durations"; auto durations_block_id = prefix + "/durations";
auto distances_block_id = prefix + "/distances";
auto weights = make_vector_view<EdgeWeight>(index, weights_block_id); auto weights = make_vector_view<EdgeWeight>(index, weights_block_id);
auto durations = make_vector_view<EdgeDuration>(index, durations_block_id); auto durations = make_vector_view<EdgeDuration>(index, durations_block_id);
auto distances = make_vector_view<EdgeDistance>(index, distances_block_id);
cell_metric_excludes.push_back(customizer::CellMetricView{ cell_metric_excludes.push_back(
std::move(weights), std::move(durations), std::move(distances)}); customizer::CellMetricView{std::move(weights), std::move(durations)});
} }
return cell_metric_excludes; return cell_metric_excludes;
@@ -337,7 +332,6 @@ inline auto make_multi_level_graph_view(const SharedDataIndex &index, const std:
index, name + "/node_to_edge_offset"); index, name + "/node_to_edge_offset");
auto node_weights = make_vector_view<EdgeWeight>(index, name + "/node_weights"); auto node_weights = make_vector_view<EdgeWeight>(index, name + "/node_weights");
auto node_durations = make_vector_view<EdgeDuration>(index, name + "/node_durations"); auto node_durations = make_vector_view<EdgeDuration>(index, name + "/node_durations");
auto node_distances = make_vector_view<EdgeDistance>(index, name + "/node_distances");
auto is_forward_edge = make_vector_view<bool>(index, name + "/is_forward_edge"); auto is_forward_edge = make_vector_view<bool>(index, name + "/is_forward_edge");
auto is_backward_edge = make_vector_view<bool>(index, name + "/is_backward_edge"); auto is_backward_edge = make_vector_view<bool>(index, name + "/is_backward_edge");
@@ -346,7 +340,6 @@ inline auto make_multi_level_graph_view(const SharedDataIndex &index, const std:
std::move(node_to_offset), std::move(node_to_offset),
std::move(node_weights), std::move(node_weights),
std::move(node_durations), std::move(node_durations),
std::move(node_distances),
std::move(is_forward_edge), std::move(is_forward_edge),
std::move(is_backward_edge)); std::move(is_backward_edge));
} }
+5 -11
View File
@@ -22,17 +22,11 @@ class Updater
std::vector<EdgeWeight> &node_weights, std::vector<EdgeWeight> &node_weights,
std::uint32_t &connectivity_checksum) const; std::uint32_t &connectivity_checksum) const;
EdgeID LoadAndUpdateEdgeExpandedGraph( EdgeID
std::vector<extractor::EdgeBasedEdge> &edge_based_edge_list, LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &edge_based_edge_list,
std::vector<EdgeWeight> &node_weights, std::vector<EdgeWeight> &node_weights,
std::vector<EdgeDuration> &node_durations, // TODO: remove when optional std::vector<EdgeDuration> &node_durations, // TODO: to be deleted
std::uint32_t &connectivity_checksum) const; std::uint32_t &connectivity_checksum) const;
EdgeID LoadAndUpdateEdgeExpandedGraph(
std::vector<extractor::EdgeBasedEdge> &edge_based_edge_list,
std::vector<EdgeWeight> &node_weights,
std::vector<EdgeDuration> &node_durations, // TODO: remove when optional
std::vector<EdgeDistance> &node_distances, // TODO: remove when optional
std::uint32_t &connectivity_checksum) const;
private: private:
UpdaterConfig config; UpdaterConfig config;
-19
View File
@@ -1,11 +1,9 @@
#ifndef OSRM_UTIL_DEBUG_HPP_ #ifndef OSRM_UTIL_DEBUG_HPP_
#define OSRM_UTIL_DEBUG_HPP_ #define OSRM_UTIL_DEBUG_HPP_
#include "extractor/edge_based_edge.hpp"
#include "extractor/node_data_container.hpp" #include "extractor/node_data_container.hpp"
#include "extractor/query_node.hpp" #include "extractor/query_node.hpp"
#include "guidance/intersection.hpp" #include "guidance/intersection.hpp"
#include "guidance/turn_instruction.hpp"
#include "guidance/turn_lane_data.hpp" #include "guidance/turn_lane_data.hpp"
#include "engine/guidance/route_step.hpp" #include "engine/guidance/route_step.hpp"
#include "util/node_based_graph.hpp" #include "util/node_based_graph.hpp"
@@ -188,23 +186,6 @@ inline std::ostream &operator<<(std::ostream &out, const LaneDataVector &turn_la
} }
} }
} }
namespace extractor
{
inline std::ostream &operator<<(std::ostream &out, const EdgeBasedEdge &edge)
{
out << " EdgeBasedEdge {";
out << " source " << edge.source << ", target: " << edge.target;
out << " EdgeBasedEdgeData data {";
out << " turn_id: " << edge.data.turn_id << ", weight: " << edge.data.weight;
out << " distance: " << edge.data.distance << ", duration: " << edge.data.duration;
out << " forward: " << (edge.data.forward == 0 ? "false" : "true")
<< ", backward: " << (edge.data.backward == 0 ? "false" : "true");
out << " }";
out << "}";
return out;
}
}
} }
#endif /*OSRM_ENGINE_GUIDANCE_DEBUG_HPP_*/ #endif /*OSRM_ENGINE_GUIDANCE_DEBUG_HPP_*/
-517
View File
@@ -1,517 +0,0 @@
#ifndef IEEE754_HPP
#define IEEE754_HPP
/**
Copyright (C) 2014 Milo Yip
Imported from:
https://github.com/miloyip/dtoa-benchmark/blob/c4020c62754950d38a1aaaed2975b05b441d1e7d/src/milo/dtoa_milo.h
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
**/
#include <assert.h>
#include <math.h>
#if defined(_MSC_VER)
#include "rapidjson/msinttypes/stdint.h"
#include <intrin.h>
#else
#include <stdint.h>
#endif
#define UINT64_C2(h, l) ((static_cast<uint64_t>(h) << 32) | static_cast<uint64_t>(l))
namespace osrm
{
namespace util
{
namespace ieee754
{
struct DiyFp
{
DiyFp() {}
DiyFp(uint64_t f, int e) : f(f), e(e) {}
DiyFp(double d)
{
union {
double d;
uint64_t u64;
} u = {d};
int biased_e = (u.u64 & kDpExponentMask) >> kDpSignificandSize;
uint64_t significand = (u.u64 & kDpSignificandMask);
if (biased_e != 0)
{
f = significand + kDpHiddenBit;
e = biased_e - kDpExponentBias;
}
else
{
f = significand;
e = kDpMinExponent + 1;
}
}
DiyFp operator-(const DiyFp &rhs) const
{
assert(e == rhs.e);
assert(f >= rhs.f);
return DiyFp(f - rhs.f, e);
}
DiyFp operator*(const DiyFp &rhs) const
{
#if defined(_MSC_VER) && defined(_M_AMD64)
uint64_t h;
uint64_t l = _umul128(f, rhs.f, &h);
if (l & (uint64_t(1) << 63)) // rounding
h++;
return DiyFp(h, e + rhs.e + 64);
#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)
unsigned __int128 p =
static_cast<unsigned __int128>(f) * static_cast<unsigned __int128>(rhs.f);
uint64_t h = p >> 64;
uint64_t l = static_cast<uint64_t>(p);
if (l & (uint64_t(1) << 63)) // rounding
h++;
return DiyFp(h, e + rhs.e + 64);
#else
const uint64_t M32 = 0xFFFFFFFF;
const uint64_t a = f >> 32;
const uint64_t b = f & M32;
const uint64_t c = rhs.f >> 32;
const uint64_t d = rhs.f & M32;
const uint64_t ac = a * c;
const uint64_t bc = b * c;
const uint64_t ad = a * d;
const uint64_t bd = b * d;
uint64_t tmp = (bd >> 32) + (ad & M32) + (bc & M32);
tmp += 1U << 31; /// mult_round
return DiyFp(ac + (ad >> 32) + (bc >> 32) + (tmp >> 32), e + rhs.e + 64);
#endif
}
DiyFp Normalize() const
{
#if defined(_MSC_VER) && defined(_M_AMD64)
unsigned long index;
_BitScanReverse64(&index, f);
return DiyFp(f << (63 - index), e - (63 - index));
#elif defined(__GNUC__)
int s = __builtin_clzll(f);
return DiyFp(f << s, e - s);
#else
DiyFp res = *this;
while (!(res.f & kDpHiddenBit))
{
res.f <<= 1;
res.e--;
}
res.f <<= (kDiySignificandSize - kDpSignificandSize - 1);
res.e = res.e - (kDiySignificandSize - kDpSignificandSize - 1);
return res;
#endif
}
DiyFp NormalizeBoundary() const
{
#if defined(_MSC_VER) && defined(_M_AMD64)
unsigned long index;
_BitScanReverse64(&index, f);
return DiyFp(f << (63 - index), e - (63 - index));
#else
DiyFp res = *this;
while (!(res.f & (kDpHiddenBit << 1)))
{
res.f <<= 1;
res.e--;
}
res.f <<= (kDiySignificandSize - kDpSignificandSize - 2);
res.e = res.e - (kDiySignificandSize - kDpSignificandSize - 2);
return res;
#endif
}
void NormalizedBoundaries(DiyFp *minus, DiyFp *plus) const
{
DiyFp pl = DiyFp((f << 1) + 1, e - 1).NormalizeBoundary();
DiyFp mi = (f == kDpHiddenBit) ? DiyFp((f << 2) - 1, e - 2) : DiyFp((f << 1) - 1, e - 1);
mi.f <<= mi.e - pl.e;
mi.e = pl.e;
*plus = pl;
*minus = mi;
}
static const int kDiySignificandSize = 64;
static const int kDpSignificandSize = 52;
static const int kDpExponentBias = 0x3FF + kDpSignificandSize;
static const int kDpMinExponent = -kDpExponentBias;
static const uint64_t kDpExponentMask = UINT64_C2(0x7FF00000, 0x00000000);
static const uint64_t kDpSignificandMask = UINT64_C2(0x000FFFFF, 0xFFFFFFFF);
static const uint64_t kDpHiddenBit = UINT64_C2(0x00100000, 0x00000000);
uint64_t f;
int e;
};
inline DiyFp GetCachedPower(int e, int *K)
{
// 10^-348, 10^-340, ..., 10^340
static const uint64_t kCachedPowers_F[] = {
UINT64_C2(0xfa8fd5a0, 0x081c0288), UINT64_C2(0xbaaee17f, 0xa23ebf76),
UINT64_C2(0x8b16fb20, 0x3055ac76), UINT64_C2(0xcf42894a, 0x5dce35ea),
UINT64_C2(0x9a6bb0aa, 0x55653b2d), UINT64_C2(0xe61acf03, 0x3d1a45df),
UINT64_C2(0xab70fe17, 0xc79ac6ca), UINT64_C2(0xff77b1fc, 0xbebcdc4f),
UINT64_C2(0xbe5691ef, 0x416bd60c), UINT64_C2(0x8dd01fad, 0x907ffc3c),
UINT64_C2(0xd3515c28, 0x31559a83), UINT64_C2(0x9d71ac8f, 0xada6c9b5),
UINT64_C2(0xea9c2277, 0x23ee8bcb), UINT64_C2(0xaecc4991, 0x4078536d),
UINT64_C2(0x823c1279, 0x5db6ce57), UINT64_C2(0xc2109436, 0x4dfb5637),
UINT64_C2(0x9096ea6f, 0x3848984f), UINT64_C2(0xd77485cb, 0x25823ac7),
UINT64_C2(0xa086cfcd, 0x97bf97f4), UINT64_C2(0xef340a98, 0x172aace5),
UINT64_C2(0xb23867fb, 0x2a35b28e), UINT64_C2(0x84c8d4df, 0xd2c63f3b),
UINT64_C2(0xc5dd4427, 0x1ad3cdba), UINT64_C2(0x936b9fce, 0xbb25c996),
UINT64_C2(0xdbac6c24, 0x7d62a584), UINT64_C2(0xa3ab6658, 0x0d5fdaf6),
UINT64_C2(0xf3e2f893, 0xdec3f126), UINT64_C2(0xb5b5ada8, 0xaaff80b8),
UINT64_C2(0x87625f05, 0x6c7c4a8b), UINT64_C2(0xc9bcff60, 0x34c13053),
UINT64_C2(0x964e858c, 0x91ba2655), UINT64_C2(0xdff97724, 0x70297ebd),
UINT64_C2(0xa6dfbd9f, 0xb8e5b88f), UINT64_C2(0xf8a95fcf, 0x88747d94),
UINT64_C2(0xb9447093, 0x8fa89bcf), UINT64_C2(0x8a08f0f8, 0xbf0f156b),
UINT64_C2(0xcdb02555, 0x653131b6), UINT64_C2(0x993fe2c6, 0xd07b7fac),
UINT64_C2(0xe45c10c4, 0x2a2b3b06), UINT64_C2(0xaa242499, 0x697392d3),
UINT64_C2(0xfd87b5f2, 0x8300ca0e), UINT64_C2(0xbce50864, 0x92111aeb),
UINT64_C2(0x8cbccc09, 0x6f5088cc), UINT64_C2(0xd1b71758, 0xe219652c),
UINT64_C2(0x9c400000, 0x00000000), UINT64_C2(0xe8d4a510, 0x00000000),
UINT64_C2(0xad78ebc5, 0xac620000), UINT64_C2(0x813f3978, 0xf8940984),
UINT64_C2(0xc097ce7b, 0xc90715b3), UINT64_C2(0x8f7e32ce, 0x7bea5c70),
UINT64_C2(0xd5d238a4, 0xabe98068), UINT64_C2(0x9f4f2726, 0x179a2245),
UINT64_C2(0xed63a231, 0xd4c4fb27), UINT64_C2(0xb0de6538, 0x8cc8ada8),
UINT64_C2(0x83c7088e, 0x1aab65db), UINT64_C2(0xc45d1df9, 0x42711d9a),
UINT64_C2(0x924d692c, 0xa61be758), UINT64_C2(0xda01ee64, 0x1a708dea),
UINT64_C2(0xa26da399, 0x9aef774a), UINT64_C2(0xf209787b, 0xb47d6b85),
UINT64_C2(0xb454e4a1, 0x79dd1877), UINT64_C2(0x865b8692, 0x5b9bc5c2),
UINT64_C2(0xc83553c5, 0xc8965d3d), UINT64_C2(0x952ab45c, 0xfa97a0b3),
UINT64_C2(0xde469fbd, 0x99a05fe3), UINT64_C2(0xa59bc234, 0xdb398c25),
UINT64_C2(0xf6c69a72, 0xa3989f5c), UINT64_C2(0xb7dcbf53, 0x54e9bece),
UINT64_C2(0x88fcf317, 0xf22241e2), UINT64_C2(0xcc20ce9b, 0xd35c78a5),
UINT64_C2(0x98165af3, 0x7b2153df), UINT64_C2(0xe2a0b5dc, 0x971f303a),
UINT64_C2(0xa8d9d153, 0x5ce3b396), UINT64_C2(0xfb9b7cd9, 0xa4a7443c),
UINT64_C2(0xbb764c4c, 0xa7a44410), UINT64_C2(0x8bab8eef, 0xb6409c1a),
UINT64_C2(0xd01fef10, 0xa657842c), UINT64_C2(0x9b10a4e5, 0xe9913129),
UINT64_C2(0xe7109bfb, 0xa19c0c9d), UINT64_C2(0xac2820d9, 0x623bf429),
UINT64_C2(0x80444b5e, 0x7aa7cf85), UINT64_C2(0xbf21e440, 0x03acdd2d),
UINT64_C2(0x8e679c2f, 0x5e44ff8f), UINT64_C2(0xd433179d, 0x9c8cb841),
UINT64_C2(0x9e19db92, 0xb4e31ba9), UINT64_C2(0xeb96bf6e, 0xbadf77d9),
UINT64_C2(0xaf87023b, 0x9bf0ee6b)};
static const int16_t kCachedPowers_E[] = {
-1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980, -954, -927, -901,
-874, -847, -821, -794, -768, -741, -715, -688, -661, -635, -608, -582, -555,
-529, -502, -475, -449, -422, -396, -369, -343, -316, -289, -263, -236, -210,
-183, -157, -130, -103, -77, -50, -24, 3, 30, 56, 83, 109, 136,
162, 189, 216, 242, 269, 295, 322, 348, 375, 402, 428, 455, 481,
508, 534, 561, 588, 614, 641, 667, 694, 720, 747, 774, 800, 827,
853, 880, 907, 933, 960, 986, 1013, 1039, 1066};
// int k = static_cast<int>(ceil((-61 - e) * 0.30102999566398114)) + 374;
double dk =
(-61 - e) * 0.30102999566398114 + 347; // dk must be positive, so can do ceiling in positive
int k = static_cast<int>(dk);
if (k != dk)
k++;
unsigned index = static_cast<unsigned>((k >> 3) + 1);
*K = -(-348 + static_cast<int>(index << 3)); // decimal exponent no need lookup table
assert(index < sizeof(kCachedPowers_F) / sizeof(kCachedPowers_F[0]));
return DiyFp(kCachedPowers_F[index], kCachedPowers_E[index]);
}
inline void
GrisuRound(char *buffer, int len, uint64_t delta, uint64_t rest, uint64_t ten_kappa, uint64_t wp_w)
{
while (rest < wp_w && delta - rest >= ten_kappa && (rest + ten_kappa < wp_w || /// closer
wp_w - rest > rest + ten_kappa - wp_w))
{
buffer[len - 1]--;
rest += ten_kappa;
}
}
inline unsigned CountDecimalDigit32(uint32_t n)
{
// Simple pure C++ implementation was faster than __builtin_clz version in this situation.
if (n < 10)
return 1;
if (n < 100)
return 2;
if (n < 1000)
return 3;
if (n < 10000)
return 4;
if (n < 100000)
return 5;
if (n < 1000000)
return 6;
if (n < 10000000)
return 7;
if (n < 100000000)
return 8;
if (n < 1000000000)
return 9;
return 10;
}
inline void
DigitGen(const DiyFp &W, const DiyFp &Mp, uint64_t delta, char *buffer, int *len, int *K)
{
static const uint32_t kPow10[] = {
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
const DiyFp one(uint64_t(1) << -Mp.e, Mp.e);
const DiyFp wp_w = Mp - W;
uint32_t p1 = static_cast<uint32_t>(Mp.f >> -one.e);
uint64_t p2 = Mp.f & (one.f - 1);
int kappa = static_cast<int>(CountDecimalDigit32(p1));
*len = 0;
while (kappa > 0)
{
uint32_t d;
switch (kappa)
{
case 10:
d = p1 / 1000000000;
p1 %= 1000000000;
break;
case 9:
d = p1 / 100000000;
p1 %= 100000000;
break;
case 8:
d = p1 / 10000000;
p1 %= 10000000;
break;
case 7:
d = p1 / 1000000;
p1 %= 1000000;
break;
case 6:
d = p1 / 100000;
p1 %= 100000;
break;
case 5:
d = p1 / 10000;
p1 %= 10000;
break;
case 4:
d = p1 / 1000;
p1 %= 1000;
break;
case 3:
d = p1 / 100;
p1 %= 100;
break;
case 2:
d = p1 / 10;
p1 %= 10;
break;
case 1:
d = p1;
p1 = 0;
break;
default:
#if defined(_MSC_VER)
__assume(0);
#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
__builtin_unreachable();
#else
d = 0;
#endif
}
if (d || *len)
buffer[(*len)++] = '0' + static_cast<char>(d);
kappa--;
uint64_t tmp = (static_cast<uint64_t>(p1) << -one.e) + p2;
if (tmp <= delta)
{
*K += kappa;
GrisuRound(
buffer, *len, delta, tmp, static_cast<uint64_t>(kPow10[kappa]) << -one.e, wp_w.f);
return;
}
}
// kappa = 0
for (;;)
{
p2 *= 10;
delta *= 10;
char d = static_cast<char>(p2 >> -one.e);
if (d || *len)
buffer[(*len)++] = '0' + d;
p2 &= one.f - 1;
kappa--;
if (p2 < delta)
{
*K += kappa;
GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * kPow10[-kappa]);
return;
}
}
}
inline void Grisu2(double value, char *buffer, int *length, int *K)
{
const DiyFp v(value);
DiyFp w_m, w_p;
v.NormalizedBoundaries(&w_m, &w_p);
const DiyFp c_mk = GetCachedPower(w_p.e, K);
const DiyFp W = v.Normalize() * c_mk;
DiyFp Wp = w_p * c_mk;
DiyFp Wm = w_m * c_mk;
Wm.f++;
Wp.f--;
DigitGen(W, Wp, Wp.f - Wm.f, buffer, length, K);
}
inline const char *GetDigitsLut()
{
static const char cDigitsLut[200] = {
'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0',
'8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',
'1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2',
'5', '2', '6', '2', '7', '2', '8', '2', '9', '3', '0', '3', '1', '3', '2', '3', '3',
'3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9', '4', '0', '4', '1', '4',
'2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0',
'5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5',
'9', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7',
'6', '8', '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7',
'6', '7', '7', '7', '8', '7', '9', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4',
'8', '5', '8', '6', '8', '7', '8', '8', '8', '9', '9', '0', '9', '1', '9', '2', '9',
'3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'};
return cDigitsLut;
}
inline void WriteExponent(int K, char *buffer)
{
if (K < 0)
{
*buffer++ = '-';
K = -K;
}
if (K >= 100)
{
*buffer++ = '0' + static_cast<char>(K / 100);
K %= 100;
const char *d = GetDigitsLut() + K * 2;
*buffer++ = d[0];
*buffer++ = d[1];
}
else if (K >= 10)
{
const char *d = GetDigitsLut() + K * 2;
*buffer++ = d[0];
*buffer++ = d[1];
}
else
*buffer++ = '0' + static_cast<char>(K);
*buffer = '\0';
}
inline void Prettify(char *buffer, int length, int k)
{
const int kk = length + k; // 10^(kk-1) <= v < 10^kk
if (length <= kk && kk <= 21)
{
// 1234e7 -> 12340000000
for (int i = length; i < kk; i++)
buffer[i] = '0';
buffer[kk] = '.';
buffer[kk + 1] = '0';
buffer[kk + 2] = '\0';
}
else if (0 < kk && kk <= 21)
{
// 1234e-2 -> 12.34
memmove(&buffer[kk + 1], &buffer[kk], length - kk);
buffer[kk] = '.';
buffer[length + 1] = '\0';
}
else if (-6 < kk && kk <= 0)
{
// 1234e-6 -> 0.001234
const int offset = 2 - kk;
memmove(&buffer[offset], &buffer[0], length);
buffer[0] = '0';
buffer[1] = '.';
for (int i = 2; i < offset; i++)
buffer[i] = '0';
buffer[length + offset] = '\0';
}
else if (length == 1)
{
// 1e30
buffer[1] = 'e';
WriteExponent(kk - 1, &buffer[2]);
}
else
{
// 1234e30 -> 1.234e33
memmove(&buffer[2], &buffer[1], length - 1);
buffer[1] = '.';
buffer[length + 1] = 'e';
WriteExponent(kk - 1, &buffer[0 + length + 2]);
}
}
inline void dtoa_milo(double value, char *buffer)
{
// Not handling NaN and inf
assert(!std::isnan(value));
assert(!std::isinf(value));
if (value == 0)
{
buffer[0] = '0';
buffer[1] = '.';
buffer[2] = '0';
buffer[3] = '\0';
}
else
{
if (value < 0)
{
*buffer++ = '-';
value = -value;
}
int length, K;
Grisu2(value, buffer, &length, &K);
Prettify(buffer, length, K);
}
}
} // namespace ieee754
} // namespace util
} // namespace osrm
#endif // IEEE754_HPP
+2 -31
View File
@@ -5,7 +5,6 @@
#define JSON_RENDERER_HPP #define JSON_RENDERER_HPP
#include "util/cast.hpp" #include "util/cast.hpp"
#include "util/ieee754.hpp"
#include "util/string_util.hpp" #include "util/string_util.hpp"
#include "osrm/json_container.hpp" #include "osrm/json_container.hpp"
@@ -22,11 +21,6 @@ namespace util
namespace json namespace json
{ {
namespace
{
constexpr int MAX_FLOAT_STRING_LENGTH = 256;
}
struct Renderer struct Renderer
{ {
explicit Renderer(std::ostream &_out) : out(_out) {} explicit Renderer(std::ostream &_out) : out(_out) {}
@@ -40,31 +34,8 @@ struct Renderer
void operator()(const Number &number) const void operator()(const Number &number) const
{ {
char buffer[MAX_FLOAT_STRING_LENGTH] = {'\0'}; out.precision(10);
ieee754::dtoa_milo(number.value, buffer); out << number.value;
// Trucate to 10 decimal places
int pos = 0;
int decimalpos = 0;
while (decimalpos == 0 && pos < MAX_FLOAT_STRING_LENGTH && buffer[pos] != 0)
{
if (buffer[pos] == '.')
{
decimalpos = pos;
break;
}
++pos;
}
while (pos < MAX_FLOAT_STRING_LENGTH && buffer[pos] != 0)
{
if (pos - decimalpos == 10)
{
buffer[pos] = '\0';
break;
}
++pos;
}
out << buffer;
} }
void operator()(const Object &object) const void operator()(const Object &object) const
+16 -17
View File
@@ -15,14 +15,14 @@ namespace util
namespace detail namespace detail
{ {
template <typename T, typename MmapContainerT> template <typename T, typename RegionT>
util::vector_view<T> mmapFile(const boost::filesystem::path &file, MmapContainerT &mmap_container) util::vector_view<T> mmapFile(const boost::filesystem::path &file, RegionT &region)
{ {
try try
{ {
mmap_container.open(file); region.open(file);
std::size_t num_objects = mmap_container.size() / sizeof(T); std::size_t num_objects = region.size() / sizeof(T);
auto data_ptr = mmap_container.data(); auto data_ptr = region.data();
BOOST_ASSERT(reinterpret_cast<uintptr_t>(data_ptr) % alignof(T) == 0); BOOST_ASSERT(reinterpret_cast<uintptr_t>(data_ptr) % alignof(T) == 0);
return util::vector_view<T>(reinterpret_cast<T *>(data_ptr), num_objects); return util::vector_view<T>(reinterpret_cast<T *>(data_ptr), num_objects);
} }
@@ -34,10 +34,9 @@ util::vector_view<T> mmapFile(const boost::filesystem::path &file, MmapContainer
} }
} }
template <typename T, typename MmapContainerT> template <typename T, typename RegionT>
util::vector_view<T> mmapFile(const boost::filesystem::path &file, util::vector_view<T>
MmapContainerT &mmap_container, mmapFile(const boost::filesystem::path &file, RegionT &region, const std::size_t size)
const std::size_t size)
{ {
try try
{ {
@@ -46,10 +45,10 @@ util::vector_view<T> mmapFile(const boost::filesystem::path &file,
params.path = file.string(); params.path = file.string();
params.flags = boost::iostreams::mapped_file::readwrite; params.flags = boost::iostreams::mapped_file::readwrite;
params.new_file_size = size; params.new_file_size = size;
mmap_container.open(params); region.open(params);
std::size_t num_objects = size / sizeof(T); std::size_t num_objects = size / sizeof(T);
auto data_ptr = mmap_container.data(); auto data_ptr = region.data();
BOOST_ASSERT(reinterpret_cast<uintptr_t>(data_ptr) % alignof(T) == 0); BOOST_ASSERT(reinterpret_cast<uintptr_t>(data_ptr) % alignof(T) == 0);
return util::vector_view<T>(reinterpret_cast<T *>(data_ptr), num_objects); return util::vector_view<T>(reinterpret_cast<T *>(data_ptr), num_objects);
} }
@@ -64,24 +63,24 @@ util::vector_view<T> mmapFile(const boost::filesystem::path &file,
template <typename T> template <typename T>
util::vector_view<const T> mmapFile(const boost::filesystem::path &file, util::vector_view<const T> mmapFile(const boost::filesystem::path &file,
boost::iostreams::mapped_file_source &mmap_container) boost::iostreams::mapped_file_source &region)
{ {
return detail::mmapFile<const T>(file, mmap_container); return detail::mmapFile<const T>(file, region);
} }
template <typename T> template <typename T>
util::vector_view<T> mmapFile(const boost::filesystem::path &file, util::vector_view<T> mmapFile(const boost::filesystem::path &file,
boost::iostreams::mapped_file &mmap_container) boost::iostreams::mapped_file &region)
{ {
return detail::mmapFile<T>(file, mmap_container); return detail::mmapFile<T>(file, region);
} }
template <typename T> template <typename T>
util::vector_view<T> mmapFile(const boost::filesystem::path &file, util::vector_view<T> mmapFile(const boost::filesystem::path &file,
boost::iostreams::mapped_file &mmap_container, boost::iostreams::mapped_file &region,
std::size_t size) std::size_t size)
{ {
return detail::mmapFile<T>(file, mmap_container, size); return detail::mmapFile<T>(file, region, size);
} }
} }
} }
+4 -10
View File
@@ -9,7 +9,6 @@
#include <tbb/parallel_sort.h> #include <tbb/parallel_sort.h>
#include <iostream>
#include <memory> #include <memory>
#include <utility> #include <utility>
@@ -21,27 +20,24 @@ namespace util
struct NodeBasedEdgeData struct NodeBasedEdgeData
{ {
NodeBasedEdgeData() NodeBasedEdgeData()
: weight(INVALID_EDGE_WEIGHT), duration(INVALID_EDGE_WEIGHT), : weight(INVALID_EDGE_WEIGHT), duration(INVALID_EDGE_WEIGHT), geometry_id({0, false}),
distance(INVALID_EDGE_DISTANCE), geometry_id({0, false}), reversed(false), reversed(false), annotation_data(-1)
annotation_data(-1)
{ {
} }
NodeBasedEdgeData(EdgeWeight weight, NodeBasedEdgeData(EdgeWeight weight,
EdgeWeight duration, EdgeWeight duration,
EdgeDistance distance,
GeometryID geometry_id, GeometryID geometry_id,
bool reversed, bool reversed,
extractor::NodeBasedEdgeClassification flags, extractor::NodeBasedEdgeClassification flags,
AnnotationID annotation_data) AnnotationID annotation_data)
: weight(weight), duration(duration), distance(distance), geometry_id(geometry_id), : weight(weight), duration(duration), geometry_id(geometry_id), reversed(reversed),
reversed(reversed), flags(flags), annotation_data(annotation_data) flags(flags), annotation_data(annotation_data)
{ {
} }
EdgeWeight weight; EdgeWeight weight;
EdgeWeight duration; EdgeWeight duration;
EdgeDistance distance;
GeometryID geometry_id; GeometryID geometry_id;
bool reversed : 1; bool reversed : 1;
extractor::NodeBasedEdgeClassification flags; extractor::NodeBasedEdgeClassification flags;
@@ -84,13 +80,11 @@ NodeBasedDynamicGraphFromEdges(NodeID number_of_nodes,
const extractor::NodeBasedEdge &input_edge) { const extractor::NodeBasedEdge &input_edge) {
output_edge.data.weight = input_edge.weight; output_edge.data.weight = input_edge.weight;
output_edge.data.duration = input_edge.duration; output_edge.data.duration = input_edge.duration;
output_edge.data.distance = input_edge.distance;
output_edge.data.flags = input_edge.flags; output_edge.data.flags = input_edge.flags;
output_edge.data.annotation_data = input_edge.annotation_data; output_edge.data.annotation_data = input_edge.annotation_data;
BOOST_ASSERT(output_edge.data.weight > 0); BOOST_ASSERT(output_edge.data.weight > 0);
BOOST_ASSERT(output_edge.data.duration > 0); BOOST_ASSERT(output_edge.data.duration > 0);
BOOST_ASSERT(output_edge.data.distance >= 0);
}); });
tbb::parallel_sort(edges_list.begin(), edges_list.end()); tbb::parallel_sort(edges_list.begin(), edges_list.end());
+1 -7
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>;
@@ -113,14 +113,8 @@ static const SegmentWeight MAX_SEGMENT_WEIGHT = INVALID_SEGMENT_WEIGHT - 1;
static const SegmentDuration MAX_SEGMENT_DURATION = INVALID_SEGMENT_DURATION - 1; static const SegmentDuration MAX_SEGMENT_DURATION = INVALID_SEGMENT_DURATION - 1;
static const EdgeWeight INVALID_EDGE_WEIGHT = std::numeric_limits<EdgeWeight>::max(); static const EdgeWeight INVALID_EDGE_WEIGHT = std::numeric_limits<EdgeWeight>::max();
static const EdgeDuration MAXIMAL_EDGE_DURATION = std::numeric_limits<EdgeDuration>::max(); static const EdgeDuration MAXIMAL_EDGE_DURATION = std::numeric_limits<EdgeDuration>::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<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
-15
View File
@@ -195,10 +195,7 @@ template <> class vector_view<bool>
{ {
BOOST_ASSERT_MSG(index < m_size, "invalid size"); BOOST_ASSERT_MSG(index < m_size, "invalid size");
const std::size_t bucket = index / WORD_BITS; const std::size_t bucket = index / WORD_BITS;
// Note: ordering of bits here should match packBits in storage/serialization.hpp
// so that directly mmap-ing data is possible
const auto offset = index % WORD_BITS; const auto offset = index % WORD_BITS;
BOOST_ASSERT(WORD_BITS > offset);
return m_ptr[bucket] & (static_cast<Word>(1) << offset); return m_ptr[bucket] & (static_cast<Word>(1) << offset);
} }
@@ -227,23 +224,11 @@ template <> class vector_view<bool>
{ {
BOOST_ASSERT(index < m_size); BOOST_ASSERT(index < m_size);
const auto bucket = index / WORD_BITS; const auto bucket = index / WORD_BITS;
// Note: ordering of bits here should match packBits in storage/serialization.hpp
// so that directly mmap-ing data is possible
const auto offset = index % WORD_BITS; const auto offset = index % WORD_BITS;
BOOST_ASSERT(WORD_BITS > offset);
return reference{m_ptr + bucket, static_cast<Word>(1) << offset}; return reference{m_ptr + bucket, static_cast<Word>(1) << offset};
} }
template <typename T> friend void swap(vector_view<T> &, vector_view<T> &) noexcept; template <typename T> friend void swap(vector_view<T> &, vector_view<T> &) noexcept;
friend std::ostream &operator<<(std::ostream &os, const vector_view<bool> &rhs)
{
for (std::size_t i = 0; i < rhs.size(); ++i)
{
os << (i > 0 ? " " : "") << rhs.at(i);
}
return os;
}
}; };
// Both vector_view<T> and the vector_view<bool> specializations share this impl. // Both vector_view<T> and the vector_view<bool> specializations share this impl.
+2899 -6734
View File
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -1,13 +1,13 @@
{ {
"name": "osrm", "name": "osrm",
"version": "5.21.0-customsnapping.4", "version": "5.18.0",
"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": {
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"nan": "^2.11.1", "nan": "^2.6.2",
"node-cmake": "^2.3.2", "node-cmake": "^2.3.2",
"node-pre-gyp": "^0.12.0", "node-pre-gyp": "^0.6.36",
"rimraf": "^2.5.4" "rimraf": "^2.5.4"
}, },
"browserify": { "browserify": {
@@ -18,7 +18,7 @@
}, },
"scripts": { "scripts": {
"lint": "node ./node_modules/eslint/bin/eslint.js -c ./.eslintrc features/step_definitions/ features/support/", "lint": "node ./node_modules/eslint/bin/eslint.js -c ./.eslintrc features/step_definitions/ features/support/",
"test": "npm run lint && node ./node_modules/cucumber/bin/cucumber.js features/ -p verify && node ./node_modules/cucumber/bin/cucumber.js features/ -p verify -m mmap && node ./node_modules/cucumber/bin/cucumber.js features/ -p mld && node ./node_modules/cucumber/bin/cucumber.js features/ -p mld -m mmap", "test": "npm run lint && node ./node_modules/cucumber/bin/cucumber.js features/ -p verify && node ./node_modules/cucumber/bin/cucumber.js features/ -p mld",
"clean": "rm -rf test/cache", "clean": "rm -rf test/cache",
"docs": "./scripts/build_api_docs.sh", "docs": "./scripts/build_api_docs.sh",
"install": "node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh", "install": "node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh",
@@ -47,14 +47,14 @@
"csv-stringify": "^3.0.0", "csv-stringify": "^3.0.0",
"cucumber": "^1.2.1", "cucumber": "^1.2.1",
"d3-queue": "^2.0.3", "d3-queue": "^2.0.3",
"docbox": "^1.0.11", "docbox": "^1.0.6",
"documentation": "^4.0.0-rc.1", "documentation": "^4.0.0-rc.1",
"eslint": "^5.10.0", "eslint": "^2.4.0",
"faucet": "^0.0.1", "faucet": "^0.0.1",
"jsonpath": "^1.0.0", "jsonpath": "^1.0.0",
"node-timeout": "0.0.4", "node-timeout": "0.0.4",
"polyline": "^0.2.0", "polyline": "^0.2.0",
"request": "^2.88.0", "request": "^2.69.0",
"tape": "^4.7.0", "tape": "^4.7.0",
"turf": "^3.0.14", "turf": "^3.0.14",
"xmlbuilder": "^4.2.1" "xmlbuilder": "^4.2.1"
+32 -9
View File
@@ -7,7 +7,6 @@ Sequence = require('lib/sequence')
Handlers = require("lib/way_handlers") Handlers = require("lib/way_handlers")
find_access_tag = require("lib/access").find_access_tag find_access_tag = require("lib/access").find_access_tag
limit = require("lib/maxspeed").limit limit = require("lib/maxspeed").limit
Measure = require("lib/measure")
function setup() function setup()
local default_speed = 15 local default_speed = 15
@@ -39,10 +38,20 @@ function setup()
mode.pushing_bike mode.pushing_bike
}, },
barrier_blacklist = Set { barrier_whitelist = Set {
'yes', 'sump_buster',
'wall', 'bus_trap',
'fence' 'cycle_barrier',
'bollard',
'entrance',
'cattle_grid',
'border_control',
'toll_booth',
'sally_port',
'gate',
'lift_gate',
'no',
'block'
}, },
access_tag_whitelist = Set { access_tag_whitelist = Set {
@@ -207,6 +216,20 @@ function setup()
} }
end end
local function parse_maxspeed(source)
if not source then
return 0
end
local n = tonumber(source:match("%d*"))
if not n then
n = 0
end
if string.match(source, "mph") or string.match(source, "mp/h") then
n = (n*1609)/1000
end
return n
end
function process_node(profile, node, result) function process_node(profile, node, result)
-- parse access and barrier tags -- parse access and barrier tags
local highway = node:get_value_by_key("highway") local highway = node:get_value_by_key("highway")
@@ -222,7 +245,7 @@ function process_node(profile, node, result)
else else
local barrier = node:get_value_by_key("barrier") local barrier = node:get_value_by_key("barrier")
if barrier and "" ~= barrier then if barrier and "" ~= barrier then
if profile.barrier_blacklist[barrier] then if not profile.barrier_whitelist[barrier] then
result.barrier = true result.barrier = true
end end
end end
@@ -263,9 +286,9 @@ function handle_bicycle_tags(profile,way,result,data)
-- other tags -- other tags
data.junction = way:get_value_by_key("junction") data.junction = way:get_value_by_key("junction")
data.maxspeed = Measure.get_max_speed(way:get_value_by_key ("maxspeed")) or 0 data.maxspeed = parse_maxspeed(way:get_value_by_key ( "maxspeed") )
data.maxspeed_forward = Measure.get_max_speed(way:get_value_by_key("maxspeed:forward")) or 0 data.maxspeed_forward = parse_maxspeed(way:get_value_by_key( "maxspeed:forward"))
data.maxspeed_backward = Measure.get_max_speed(way:get_value_by_key("maxspeed:backward")) or 0 data.maxspeed_backward = parse_maxspeed(way:get_value_by_key( "maxspeed:backward"))
data.barrier = way:get_value_by_key("barrier") data.barrier = way:get_value_by_key("barrier")
data.oneway = way:get_value_by_key("oneway") data.oneway = way:get_value_by_key("oneway")
data.oneway_bicycle = way:get_value_by_key("oneway:bicycle") data.oneway_bicycle = way:get_value_by_key("oneway:bicycle")
-8
View File
@@ -42,10 +42,6 @@ function setup()
vehicle_height = 2.5, -- in meters, 2.5m is the height of van vehicle_height = 2.5, -- in meters, 2.5m is the height of van
vehicle_width = 1.9, -- in meters, ways with narrow tag are considered narrower than 2.2m vehicle_width = 1.9, -- in meters, ways with narrow tag are considered narrower than 2.2m
-- Size of the vehicle, to be limited mostly by legal restriction of the way
vehicle_length = 4.8, -- in meters, 4.8m is the length of large or familly car
vehicle_weight = 3500, -- in kilograms
-- a list of suffixes to suppress in name change instructions. The suffixes also include common substrings of each other -- a list of suffixes to suppress in name change instructions. The suffixes also include common substrings of each other
suffix_list = { suffix_list = {
'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW', 'North', 'South', 'West', 'East', 'Nor', 'Sou', 'We', 'Ea' 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW', 'North', 'South', 'West', 'East', 'Nor', 'Sou', 'We', 'Ea'
@@ -269,7 +265,6 @@ function setup()
["at:rural"] = 100, ["at:rural"] = 100,
["at:trunk"] = 100, ["at:trunk"] = 100,
["be:motorway"] = 120, ["be:motorway"] = 120,
["be-vlg:rural"] = 70,
["by:urban"] = 60, ["by:urban"] = 60,
["by:motorway"] = 110, ["by:motorway"] = 110,
["ch:rural"] = 80, ["ch:rural"] = 80,
@@ -281,7 +276,6 @@ function setup()
["de:rural"] = 100, ["de:rural"] = 100,
["de:motorway"] = 0, ["de:motorway"] = 0,
["dk:rural"] = 80, ["dk:rural"] = 80,
["fr:rural"] = 80,
["gb:nsl_single"] = (60*1609)/1000, ["gb:nsl_single"] = (60*1609)/1000,
["gb:nsl_dual"] = (70*1609)/1000, ["gb:nsl_dual"] = (70*1609)/1000,
["gb:motorway"] = (70*1609)/1000, ["gb:motorway"] = (70*1609)/1000,
@@ -393,8 +387,6 @@ function process_way(profile, way, result, relations)
WayHandlers.avoid_ways, WayHandlers.avoid_ways,
WayHandlers.handle_height, WayHandlers.handle_height,
WayHandlers.handle_width, WayHandlers.handle_width,
WayHandlers.handle_length,
WayHandlers.handle_weight,
-- determine access status by checking our hierarchy of -- determine access status by checking our hierarchy of
-- access tags, e.g: motorcar, motor_vehicle, vehicle -- access tags, e.g: motorcar, motor_vehicle, vehicle
+14 -5
View File
@@ -24,10 +24,19 @@ function setup()
default_speed = walking_speed, default_speed = walking_speed,
oneway_handling = 'specific', -- respect 'oneway:foot' but not 'oneway' oneway_handling = 'specific', -- respect 'oneway:foot' but not 'oneway'
barrier_blacklist = Set { barrier_whitelist = Set {
'yes', 'cycle_barrier',
'wall', 'bollard',
'fence' 'entrance',
'cattle_grid',
'border_control',
'toll_booth',
'sally_port',
'gate',
'lift_gate',
'no',
'kerb',
'block'
}, },
access_tag_whitelist = Set { access_tag_whitelist = Set {
@@ -148,7 +157,7 @@ function process_node(profile, node, result)
local bollard = node:get_value_by_key("bollard") local bollard = node:get_value_by_key("bollard")
local rising_bollard = bollard and "rising" == bollard local rising_bollard = bollard and "rising" == bollard
if profile.barrier_blacklist[barrier] and not rising_bollard then if not profile.barrier_whitelist[barrier] and not rising_bollard then
result.barrier = true result.barrier = true
end end
end end
+27 -40
View File
@@ -5,19 +5,6 @@ Measure = {}
-- measurements conversion constants -- measurements conversion constants
local inch_to_meters = 0.0254 local inch_to_meters = 0.0254
local feet_to_inches = 12 local feet_to_inches = 12
local pound_to_kilograms = 0.45359237
local miles_to_kilometers = 1.609
-- Parse speed value as kilometers by hours.
function Measure.parse_value_speed(source)
local n = tonumber(source:match("%d*"))
if n then
if string.match(source, "mph") or string.match(source, "mp/h") then
n = n * miles_to_kilometers
end
return n
end
end
--- Parse string as a height in meters. --- Parse string as a height in meters.
--- according to http://wiki.openstreetmap.org/wiki/Key:maxheight --- according to http://wiki.openstreetmap.org/wiki/Key:maxheight
@@ -38,26 +25,33 @@ function Measure.parse_value_meters(value)
end end
end end
--- Parse weight value in kilograms. --- according to http://wiki.openstreetmap.org/wiki/Map_Features/Units#Explicit_specifications
--- according to https://wiki.openstreetmap.org/wiki/Key:maxweight local tonns_parse_patterns = Sequence {
function Measure.parse_value_kilograms(value) "%d+",
local n = tonumber(value:gsub(",", "."):match("%d+%.?%d*")) "%d+.%d+",
if n then "%d+.%d+ ?t"
if string.match(value, "lbs") then }
n = n * pound_to_kilograms
elseif string.match(value, "kg") then
-- n = n
else -- Default, metric tons
n = n * 1000
end
return n
end
end
--- Get maxspeed of specified way in kilometers by hours. local kg_parse_patterns = Sequence {
function Measure.get_max_speed(raw_value) "%d+ ?kg"
if raw_value then }
return Measure.parse_value_speed(raw_value)
--- Parse weight value in kilograms
function Measure.parse_value_kilograms(value)
-- try to parse kilograms
for i, templ in ipairs(kg_parse_patterns) do
m = string.match(value, templ)
if m then
return tonumber(m)
end
end
-- try to parse tonns
for i, templ in ipairs(tonns_parse_patterns) do
m = string.match(value, templ)
if m then
return tonumber(m) * 1000
end
end end
end end
@@ -89,14 +83,7 @@ function Measure.get_max_width(raw_value)
end end
end end
--- Get maxlength of specified way in meters. --- Get maxweight of specified way in kilogramms
function Measure.get_max_length(raw_value)
if raw_value then
return Measure.parse_value_meters(raw_value)
end
end
--- Get maxweight of specified way in kilogramms.
function Measure.get_max_weight(raw_value) function Measure.get_max_weight(raw_value)
if raw_value then if raw_value then
return Measure.parse_value_kilograms(raw_value) return Measure.parse_value_kilograms(raw_value)
+7 -36
View File
@@ -432,7 +432,7 @@ end
-- maxspeed and advisory maxspeed -- maxspeed and advisory maxspeed
function WayHandlers.maxspeed(profile,way,result,data) function WayHandlers.maxspeed(profile,way,result,data)
local keys = Sequence { 'maxspeed:advisory', 'maxspeed', 'source:maxspeed', 'maxspeed:type' } local keys = Sequence { 'maxspeed:advisory', 'maxspeed' }
local forward, backward = Tags.get_forward_backward_by_set(way,data,keys) local forward, backward = Tags.get_forward_backward_by_set(way,data,keys)
forward = WayHandlers.parse_maxspeed(forward,profile) forward = WayHandlers.parse_maxspeed(forward,profile)
backward = WayHandlers.parse_maxspeed(backward,profile) backward = WayHandlers.parse_maxspeed(backward,profile)
@@ -450,9 +450,12 @@ function WayHandlers.parse_maxspeed(source,profile)
if not source then if not source then
return 0 return 0
end end
local n = tonumber(source:match("%d*"))
local n = Measure.get_max_speed(source) if n then
if not n then if string.match(source, "mph") or string.match(source, "mp/h") then
n = (n*1609)/1000
end
else
-- parse maxspeed like FR:urban -- parse maxspeed like FR:urban
source = string.lower(source) source = string.lower(source)
n = profile.maxspeed_table[source] n = profile.maxspeed_table[source]
@@ -508,38 +511,6 @@ function WayHandlers.handle_width(profile,way,result,data)
end end
end end
-- handle maxweight tags
function WayHandlers.handle_weight(profile,way,result,data)
local keys = Sequence { 'maxweight' }
local forward, backward = Tags.get_forward_backward_by_set(way,data,keys)
forward = Measure.get_max_weight(forward)
backward = Measure.get_max_weight(backward)
if forward and forward < profile.vehicle_weight then
result.forward_mode = mode.inaccessible
end
if backward and backward < profile.vehicle_weight then
result.backward_mode = mode.inaccessible
end
end
-- handle maxlength tags
function WayHandlers.handle_length(profile,way,result,data)
local keys = Sequence { 'maxlength' }
local forward, backward = Tags.get_forward_backward_by_set(way,data,keys)
forward = Measure.get_max_length(forward)
backward = Measure.get_max_length(backward)
if forward and forward < profile.vehicle_length then
result.forward_mode = mode.inaccessible
end
if backward and backward < profile.vehicle_length then
result.backward_mode = mode.inaccessible
end
end
-- handle oneways tags -- handle oneways tags
function WayHandlers.oneway(profile,way,result,data) function WayHandlers.oneway(profile,way,result,data)
if not profile.oneway_handling then if not profile.oneway_handling then
+2 -6
View File
@@ -6,12 +6,8 @@ var fs = require('fs');
var name = process.argv[2]; var name = process.argv[2];
var cmd = process.argv.slice(3).join(' '); var cmd = process.argv.slice(3).join(' ');
var start = Date.now(); var start = Date.now();
exec(cmd, (err, stdout, stderr) => { exec(cmd, (err) => {
if (err) { if (err) return console.log(err);
console.log(stdout);
console.log(stderr);
return process.exit(err.code);
}
var stop = +new Date(); var stop = +new Date();
var time = (stop - start) / 1000.; var time = (stop - start) / 1000.;
fs.appendFileSync('/tmp/osrm.timings', `${name}\t${time}`, 'utf-8'); fs.appendFileSync('/tmp/osrm.timings', `${name}\t${time}`, 'utf-8');
-4
View File
@@ -215,7 +215,6 @@ void ContractNode(ContractorThreadData *data,
target, target,
path_weight, path_weight,
in_data.duration + out_data.duration, in_data.duration + out_data.duration,
in_data.distance + out_data.distance,
out_data.originalEdges + in_data.originalEdges, out_data.originalEdges + in_data.originalEdges,
node, node,
SHORTCUT_ARC, SHORTCUT_ARC,
@@ -226,7 +225,6 @@ void ContractNode(ContractorThreadData *data,
source, source,
path_weight, path_weight,
in_data.duration + out_data.duration, in_data.duration + out_data.duration,
in_data.distance + out_data.distance,
out_data.originalEdges + in_data.originalEdges, out_data.originalEdges + in_data.originalEdges,
node, node,
SHORTCUT_ARC, SHORTCUT_ARC,
@@ -282,7 +280,6 @@ void ContractNode(ContractorThreadData *data,
target, target,
path_weight, path_weight,
in_data.duration + out_data.duration, in_data.duration + out_data.duration,
in_data.distance + out_data.distance,
out_data.originalEdges + in_data.originalEdges, out_data.originalEdges + in_data.originalEdges,
node, node,
SHORTCUT_ARC, SHORTCUT_ARC,
@@ -293,7 +290,6 @@ void ContractNode(ContractorThreadData *data,
source, source,
path_weight, path_weight,
in_data.duration + out_data.duration, in_data.duration + out_data.duration,
in_data.distance + out_data.distance,
out_data.originalEdges + in_data.originalEdges, out_data.originalEdges + in_data.originalEdges,
node, node,
SHORTCUT_ARC, SHORTCUT_ARC,
+4 -10
View File
@@ -76,7 +76,6 @@ auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
const partitioner::MultiLevelPartition &mlp, const partitioner::MultiLevelPartition &mlp,
std::vector<EdgeWeight> &node_weights, std::vector<EdgeWeight> &node_weights,
std::vector<EdgeDuration> &node_durations, std::vector<EdgeDuration> &node_durations,
std::vector<EdgeDistance> &node_distances,
std::uint32_t &connectivity_checksum) std::uint32_t &connectivity_checksum)
{ {
updater::Updater updater(config.updater_config); updater::Updater updater(config.updater_config);
@@ -85,8 +84,6 @@ auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
EdgeID num_nodes = updater.LoadAndUpdateEdgeExpandedGraph( EdgeID num_nodes = updater.LoadAndUpdateEdgeExpandedGraph(
edge_based_edge_list, node_weights, node_durations, connectivity_checksum); edge_based_edge_list, node_weights, node_durations, connectivity_checksum);
extractor::files::readEdgeBasedNodeDistances(config.GetPath(".osrm.enw"), node_distances);
auto directed = partitioner::splitBidirectionalEdges(edge_based_edge_list); auto directed = partitioner::splitBidirectionalEdges(edge_based_edge_list);
auto tidied = partitioner::prepareEdgesForUsageInGraph< auto tidied = partitioner::prepareEdgesForUsageInGraph<
@@ -127,11 +124,10 @@ int Customizer::Run(const CustomizationConfig &config)
partitioner::files::readPartition(config.GetPath(".osrm.partition"), mlp); partitioner::files::readPartition(config.GetPath(".osrm.partition"), mlp);
std::vector<EdgeWeight> node_weights; std::vector<EdgeWeight> node_weights;
std::vector<EdgeDuration> node_durations; // TODO: remove when durations are optional std::vector<EdgeDuration> node_durations; // TODO: to be removed later
std::vector<EdgeDistance> node_distances; // TODO: remove when distances are optional
std::uint32_t connectivity_checksum = 0; std::uint32_t connectivity_checksum = 0;
auto graph = LoadAndUpdateEdgeExpandedGraph( auto graph = LoadAndUpdateEdgeExpandedGraph(
config, mlp, node_weights, node_durations, node_distances, connectivity_checksum); config, mlp, node_weights, node_durations, connectivity_checksum);
BOOST_ASSERT(graph.GetNumberOfNodes() == node_weights.size()); BOOST_ASSERT(graph.GetNumberOfNodes() == node_weights.size());
std::for_each(node_weights.begin(), node_weights.end(), [](auto &w) { w &= 0x7fffffff; }); std::for_each(node_weights.begin(), node_weights.end(), [](auto &w) { w &= 0x7fffffff; });
util::Log() << "Loaded edge based graph: " << graph.GetNumberOfEdges() << " edges, " util::Log() << "Loaded edge based graph: " << graph.GetNumberOfEdges() << " edges, "
@@ -170,10 +166,8 @@ int Customizer::Run(const CustomizationConfig &config)
util::Log() << "MLD customization writing took " << TIMER_SEC(writing_mld_data) << " seconds"; util::Log() << "MLD customization writing took " << TIMER_SEC(writing_mld_data) << " seconds";
TIMER_START(writing_graph); TIMER_START(writing_graph);
MultiLevelEdgeBasedGraph shaved_graph{std::move(graph), MultiLevelEdgeBasedGraph shaved_graph{
std::move(node_weights), std::move(graph), std::move(node_weights), std::move(node_durations)};
std::move(node_durations),
std::move(node_distances)};
customizer::files::writeGraph( customizer::files::writeGraph(
config.GetPath(".osrm.mldgr"), shaved_graph, connectivity_checksum); config.GetPath(".osrm.mldgr"), shaved_graph, connectivity_checksum);
TIMER_STOP(writing_graph); TIMER_STOP(writing_graph);
+4 -9
View File
@@ -94,7 +94,7 @@ std::string waypointTypeToString(const guidance::WaypointType waypoint_type)
return waypoint_type_names[static_cast<std::size_t>(waypoint_type)]; return waypoint_type_names[static_cast<std::size_t>(waypoint_type)];
} }
util::json::Array coordinateToLonLat(const util::Coordinate &coordinate) util::json::Array coordinateToLonLat(const util::Coordinate coordinate)
{ {
util::json::Array array; util::json::Array array;
array.values.push_back(static_cast<double>(util::toFloating(coordinate.lon))); array.values.push_back(static_cast<double>(util::toFloating(coordinate.lon)));
@@ -240,22 +240,17 @@ util::json::Object makeRoute(const guidance::Route &route,
return json_route; return json_route;
} }
util::json::Object util::json::Object makeWaypoint(const util::Coordinate location, std::string name)
makeWaypoint(const util::Coordinate &location, const double &distance, std::string name)
{ {
util::json::Object waypoint; util::json::Object waypoint;
waypoint.values["location"] = detail::coordinateToLonLat(location); waypoint.values["location"] = detail::coordinateToLonLat(location);
waypoint.values["name"] = std::move(name); waypoint.values["name"] = std::move(name);
waypoint.values["distance"] = distance;
return waypoint; return waypoint;
} }
util::json::Object makeWaypoint(const util::Coordinate &location, util::json::Object makeWaypoint(const util::Coordinate location, std::string name, const Hint &hint)
const double &distance,
std::string name,
const Hint &hint)
{ {
auto waypoint = makeWaypoint(location, distance, name); auto waypoint = makeWaypoint(location, name);
waypoint.values["hint"] = hint.ToBase64(); waypoint.values["hint"] = hint.ToBase64();
return waypoint; return waypoint;
} }

Some files were not shown because too many files have changed in this diff Show More