Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49e09294bf | |||
| 4a4d7ac62f | |||
| 91a24bf537 | |||
| 01f050cebb | |||
| 7ff8428ad1 | |||
| ddb25cdf22 | |||
| 524f8cc312 | |||
| d9ecb8693f | |||
| 0bf0535a8a | |||
| 2cc32dcc88 | |||
| 8ba516c17e | |||
| 4e0c018dff | |||
| 6bd74c287b |
@@ -68,10 +68,6 @@ Thumbs.db
|
||||
/*.local.bat
|
||||
/CMakeSettings.json
|
||||
|
||||
# Jetbrains related files #
|
||||
###########################
|
||||
.idea/
|
||||
|
||||
# stxxl related files #
|
||||
#######################
|
||||
.stxxl
|
||||
|
||||
+65
-60
@@ -13,12 +13,11 @@ notifications:
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- 5.21
|
||||
# enable building tags
|
||||
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
|
||||
|
||||
cache:
|
||||
npm: true
|
||||
yarn: true
|
||||
ccache: true
|
||||
apt: true
|
||||
directories:
|
||||
@@ -35,7 +34,7 @@ env:
|
||||
- CMAKE_VERSION=3.7.2
|
||||
- MASON="$(pwd)/scripts/mason.sh"
|
||||
- ENABLE_NODE_BINDINGS=On
|
||||
- NODE="10"
|
||||
- NODE="4"
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
@@ -46,7 +45,7 @@ matrix:
|
||||
# Debug Builds
|
||||
- os: linux
|
||||
compiler: "format-taginfo-docs"
|
||||
env: NODE=10
|
||||
env: NODE=6
|
||||
sudo: false
|
||||
before_install:
|
||||
install:
|
||||
@@ -54,7 +53,8 @@ matrix:
|
||||
- nvm install $NODE
|
||||
- nvm use $NODE
|
||||
- npm --version
|
||||
- npm ci --ignore-scripts
|
||||
- npm install --ignore-scripts
|
||||
- npm link --ignore-scripts
|
||||
script:
|
||||
- ./scripts/check_taginfo.py taginfo.json profiles/car.lua
|
||||
- ${MASON} install clang-format 3.8.1
|
||||
@@ -156,17 +156,17 @@ matrix:
|
||||
|
||||
- os: osx
|
||||
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
|
||||
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:
|
||||
- ./scripts/travis/publish.sh
|
||||
|
||||
- os: osx
|
||||
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
|
||||
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:
|
||||
- ./scripts/travis/publish.sh
|
||||
|
||||
@@ -180,6 +180,54 @@ matrix:
|
||||
env: CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release' BUILD_SHARED_LIBS=ON
|
||||
|
||||
# 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
|
||||
sudo: false
|
||||
compiler: "node-8-mason-linux-release"
|
||||
@@ -228,54 +276,6 @@ matrix:
|
||||
after_success:
|
||||
- ./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:
|
||||
- source $NVM_DIR/nvm.sh
|
||||
- nvm install $NODE
|
||||
@@ -294,10 +294,15 @@ before_install:
|
||||
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
||||
sudo mdutil -i off /
|
||||
fi
|
||||
- |
|
||||
if [[ ! -f $(which yarn) ]]; then
|
||||
npm install -g yarn
|
||||
fi
|
||||
- export PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
|
||||
- export PUBLISH=$([[ "${TRAVIS_TAG:-}" == "v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off")
|
||||
- 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
|
||||
- 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}"
|
||||
@@ -360,7 +365,7 @@ install:
|
||||
script:
|
||||
- if [[ $TARGET_ARCH == armhf ]] ; then echo "Skip tests for $TARGET_ARCH" && exit 0 ; fi
|
||||
- make -C test/data benchmark
|
||||
- ./example/build/osrm-example test/data/mld/monaco.osrm
|
||||
# - ./example/build/osrm-example test/data/mld/monaco.osrm
|
||||
# All tests assume to be run from the build directory
|
||||
- pushd ${OSRM_BUILD_DIR}
|
||||
- ./unit_tests/library-tests
|
||||
@@ -376,4 +381,4 @@ script:
|
||||
fi
|
||||
- |
|
||||
- popd
|
||||
- npm test
|
||||
- yarn test
|
||||
|
||||
+2
-42
@@ -1,49 +1,9 @@
|
||||
# 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
|
||||
# UNRELEASED
|
||||
- Changes from 5.18.0:
|
||||
- Optimizations:
|
||||
- CHANGED: Map matching is now almost twice as fast. [#5060](https://github.com/Project-OSRM/osrm-backend/pull/5060)
|
||||
- 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:
|
||||
|
||||
@@ -50,7 +50,7 @@ If you want to use the CH pipeline instead replace `osrm-partition` and `osrm-cu
|
||||
|
||||
### 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/)
|
||||
|
||||
|
||||
+13
-12
@@ -1,13 +1,15 @@
|
||||
FROM debian:buster-slim as builder
|
||||
FROM alpine:3.6 as buildstage
|
||||
|
||||
ARG DOCKER_TAG
|
||||
RUN mkdir -p /src && mkdir -p /opt
|
||||
COPY . /src
|
||||
WORKDIR /src
|
||||
|
||||
RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
|
||||
apt-get update && \
|
||||
apt-get -y --no-install-recommends install cmake make git gcc g++ libbz2-dev libstxxl-dev libstxxl1v5 libxml2-dev \
|
||||
libzip-dev libboost1.67-all-dev lua5.2 liblua5.2-dev libtbb-dev -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 && \
|
||||
echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
|
||||
apk update && \
|
||||
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) && \
|
||||
echo "Building OSRM ${DOCKER_TAG}" && \
|
||||
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 && \
|
||||
cd ../profiles && \
|
||||
cp -r * /opt && \
|
||||
\
|
||||
strip /usr/local/bin/* && \
|
||||
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
|
||||
# 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 apt-get update && \
|
||||
apt-get install -y --no-install-recommends libboost-program-options1.67.0 libboost-regex1.67.0 \
|
||||
libboost-date-time1.67.0 libboost-chrono1.67.0 libboost-filesystem1.67.0 \
|
||||
libboost-iostreams1.67.0 libboost-thread1.67.0 expat liblua5.2-0 libtbb2 &&\
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=builder /usr/local /usr/local
|
||||
COPY --from=builder /opt /opt
|
||||
RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
|
||||
apk update && \
|
||||
apk add boost-filesystem boost-program_options boost-regex boost-iostreams boost-thread libgomp lua5.2 expat libtbb@testing
|
||||
COPY --from=buildstage /usr/local /usr/local
|
||||
COPY --from=buildstage /opt /opt
|
||||
WORKDIR /opt
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
+3
-11
@@ -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.
|
||||
- `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.
|
||||
|
||||
#### 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. |
|
||||
|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. |
|
||||
|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.|
|
||||
|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.
|
||||
|
|
||||
|
||||
Unlike other array encoded options, the length of `sources` and `destinations` can be **smaller or equal**
|
||||
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.
|
||||
- `sources` array of `Waypoint` objects describing all sources 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:
|
||||
|
||||
@@ -385,10 +383,6 @@ All other properties might be undefined.
|
||||
2361.73,
|
||||
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. |
|
||||
| `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 |
|
||||
| `is_startpoint` | `boolean` | whether this segment can be used as a start/endpoint for routes |
|
||||
|
||||
`turns` layer:
|
||||
|
||||
@@ -912,7 +905,6 @@ Object used to describe waypoint on a route.
|
||||
|
||||
- `name` Name of the street the coordinate snapped to
|
||||
- `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)
|
||||
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.
|
||||
|
||||
+19
-23
@@ -25,9 +25,7 @@ var osrm = new OSRM('network.osrm');
|
||||
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.
|
||||
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*
|
||||
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.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.
|
||||
- `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_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.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`
|
||||
- `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**
|
||||
|
||||
@@ -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.
|
||||
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`.
|
||||
- `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**
|
||||
|
||||
@@ -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 <
|
||||
#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.fallback_speed` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Replace `null` responses in result with as-the-crow-flies estimates based on `fallback_speed`. Value is in metres/second.
|
||||
- `options.fallback_coordinate` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Either `input` (default) or `snapped`. If using a `fallback_speed`, use either the user-supplied coordinate (`input`), or the snapped coordinate (`snapped`) for calculating the as-the-crow-flies diestance between two points.
|
||||
- `options.scale_factor` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Multiply the table duration values in the table by this number for more controlled input into a route optimization solver.
|
||||
- `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**
|
||||
|
||||
@@ -157,7 +152,6 @@ Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer
|
||||
Values are given in seconds.
|
||||
**`sources`**: array of [`Ẁaypoint`](#waypoint) objects describing all sources 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
|
||||
|
||||
@@ -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
|
||||
[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/).
|
||||
- `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**
|
||||
|
||||
@@ -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.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`).
|
||||
- `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**
|
||||
|
||||
@@ -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.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`.
|
||||
- `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**
|
||||
|
||||
@@ -328,14 +322,16 @@ osrm.route(options, { format: "json_buffer" }, function(err, response) {
|
||||
|
||||
## Responses
|
||||
|
||||
Responses
|
||||
|
||||
### Route
|
||||
|
||||
Represents a route through (potentially multiple) waypoints.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- **documentation** in
|
||||
[`osrm-backend`](../http.md#route-object)
|
||||
- `exteral` **documentation** in
|
||||
[`osrm-backend`](../http.md#route)
|
||||
|
||||
### RouteLeg
|
||||
|
||||
@@ -343,8 +339,8 @@ Represents a route between two waypoints.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- **documentation** in
|
||||
[`osrm-backend`](../http.md#routeleg-object)
|
||||
- `exteral` **documentation** in
|
||||
[`osrm-backend`](../http.md#routeleg)
|
||||
|
||||
### RouteStep
|
||||
|
||||
@@ -353,15 +349,15 @@ single way to the subsequent step.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- **documentation** in
|
||||
[`osrm-backend`](../http.md#routestep-object)
|
||||
- `exteral` **documentation** in
|
||||
[`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#routestep)
|
||||
|
||||
### StepManeuver
|
||||
|
||||
**Parameters**
|
||||
|
||||
- **documentation** in
|
||||
[`osrm-backend`](../http.md#stepmaneuver-object)
|
||||
- `exteral` **documentation** in
|
||||
[`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#stepmaneuver)
|
||||
|
||||
### Waypoint
|
||||
|
||||
@@ -369,5 +365,5 @@ Object used to describe waypoint on a route.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- **documentation** in
|
||||
[`osrm-backend`](../http.md#waypoint-object)
|
||||
- `exteral` **documentation** in
|
||||
[`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#waypoint)
|
||||
|
||||
@@ -109,12 +109,3 @@ Feature: Car - Handle ferry routes
|
||||
When I route I should get
|
||||
| from | to | route | modes | time |
|
||||
| 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 |
|
||||
|
||||
@@ -137,28 +137,3 @@ OSRM will use 4/5 of the projected free-flow speed.
|
||||
| primary | | | 30 | -1 | | 23 km/h | | 6.7 |
|
||||
| primary | 20 | 30 | | -1 | | 15 km/h | | 4.4 |
|
||||
| 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 |
|
||||
@@ -84,47 +84,7 @@ class OSRMDirectLoader extends OSRMBaseLoader {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -175,32 +135,22 @@ class OSRMLoader {
|
||||
this.scope = scope;
|
||||
this.sharedLoader = new OSRMDatastoreLoader(this.scope);
|
||||
this.directLoader = new OSRMDirectLoader(this.scope);
|
||||
this.mmapLoader = new OSRMmmapLoader(this.scope);
|
||||
this.method = scope.DEFAULT_LOAD_METHOD;
|
||||
}
|
||||
|
||||
load (inputFile, callback) {
|
||||
if (!this.loader) {
|
||||
this.loader = {shutdown: (cb) => cb() };
|
||||
}
|
||||
if (this.method === 'datastore') {
|
||||
this.loader.shutdown((err) => {
|
||||
this.directLoader.shutdown((err) => {
|
||||
if (err) return callback(err);
|
||||
this.loader = this.sharedLoader;
|
||||
this.sharedLoader.load(inputFile, callback);
|
||||
});
|
||||
} else if (this.method === 'directly') {
|
||||
this.loader.shutdown((err) => {
|
||||
this.sharedLoader.shutdown((err) => {
|
||||
if (err) return callback(err);
|
||||
this.loader = this.directLoader;
|
||||
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 {
|
||||
callback(new Error('*** Unknown load method ' + method));
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ module.exports = function () {
|
||||
this.reprocess(callback);
|
||||
});
|
||||
|
||||
this.Given(/^osrm-routed is stopped$/, (callback) => {
|
||||
this.Given(/^osrm\-routed is stopped$/, (callback) => {
|
||||
this.OSRMLoader.shutdown(callback);
|
||||
});
|
||||
|
||||
|
||||
@@ -3,25 +3,22 @@ var util = require('util');
|
||||
module.exports = function () {
|
||||
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 estimatesRegex = new RegExp(/^I request a travel time matrix I should get estimates for$/);
|
||||
|
||||
const DURATIONS_NO_ROUTE = 2147483647; // MAX_INT
|
||||
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(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 distancesParse = function(v) { return isNaN(parseFloat(v)); };
|
||||
const estimatesParse = function(v) { return isNaN(parseFloat(v)); };
|
||||
|
||||
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;
|
||||
params.annotations = ['durations','fallback_speed_cells'].indexOf(annotation) !== -1 ? 'duration' : 'distance';
|
||||
params.annotations = annotation == 'distances' ? 'distance' : 'duration';
|
||||
|
||||
var tableRows = table.raw();
|
||||
|
||||
@@ -64,26 +61,11 @@ function tableParse(table, noRoute, annotation, callback) {
|
||||
|
||||
var json = JSON.parse(response.body);
|
||||
|
||||
var result = {};
|
||||
if (annotation === 'fallback_speed_cells') {
|
||||
result = table.raw().map(row => row.map(() => ''));
|
||||
json[annotation].forEach(pair => {
|
||||
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 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) => {
|
||||
for (var k in result[ri]) {
|
||||
|
||||
@@ -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.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;
|
||||
this.runAndSafeOutput('osrm-' + binary, options, (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.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);
|
||||
if (input !== undefined)
|
||||
child.stdin.write(input);
|
||||
@@ -55,13 +55,13 @@ module.exports = function () {
|
||||
this.Then(/^stdout should( not)? contain "(.*?)"$/, (not, str) => {
|
||||
const contains = this.stdout.indexOf(str) > -1;
|
||||
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) => {
|
||||
const contains = this.stderr.indexOf(str) > -1;
|
||||
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) => {
|
||||
|
||||
@@ -69,7 +69,7 @@ module.exports = function () {
|
||||
outputRow[direction] = result[direction].status ?
|
||||
'x' : '';
|
||||
break;
|
||||
case /^[\d.]+ s/.test(want):
|
||||
case /^[\d\.]+ s/.test(want):
|
||||
// the result here can come back as a non-number value like
|
||||
// `diff`, but we only want to apply the unit when it comes
|
||||
// back as a number, for tableDiff's literal comparison
|
||||
|
||||
@@ -29,7 +29,7 @@ module.exports = function() {
|
||||
|
||||
// setup cache for feature data
|
||||
// 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) => {
|
||||
if (err) return callback(err);
|
||||
|
||||
@@ -45,10 +45,10 @@ module.exports = function() {
|
||||
this.featureProcessedCacheDirectories[uri] = featureProcessedCacheDirectory;
|
||||
|
||||
d3.queue(1)
|
||||
.defer(mkdirp, featureProcessedCacheDirectory)
|
||||
.defer(this.cleanupFeatureCache.bind(this), featureCacheDirectory, hash)
|
||||
.defer(this.cleanupProcessedFeatureCache.bind(this), featureProcessedCacheDirectory, this.osrmHash)
|
||||
.awaitAll(callback);
|
||||
.defer(mkdirp, featureProcessedCacheDirectory)
|
||||
.defer(this.cleanupFeatureCache.bind(this), featureCacheDirectory, hash)
|
||||
.defer(this.cleanupProcessedFeatureCache.bind(this), featureProcessedCacheDirectory, this.osrmHash)
|
||||
.awaitAll(callback);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ module.exports = function() {
|
||||
fs.readdir(parentPath, (err, files) => {
|
||||
let q = d3.queue();
|
||||
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);
|
||||
});
|
||||
};
|
||||
@@ -145,7 +145,7 @@ module.exports = function() {
|
||||
|
||||
// converts the scenario titles in file prefixes
|
||||
this.getScenarioID = (scenario) => {
|
||||
let name = scenario.getName().toLowerCase().replace(/[/\-'=,():*#]/g, '')
|
||||
let name = scenario.getName().toLowerCase().replace(/[\/\-'=,\(\):\*#]/g, '')
|
||||
.replace(/\s/g, '_').replace(/__/g, '_').replace(/\.\./g, '.')
|
||||
.substring(0, 64);
|
||||
return util.format('%d_%s', scenario.getLine(), name);
|
||||
|
||||
@@ -17,12 +17,12 @@ module.exports = {
|
||||
return true;
|
||||
|
||||
var matchPercent = want.match(/(.*)\s+~(.+)%$/),
|
||||
matchAbs = want.match(/(.*)\s+\+-(.+)$/),
|
||||
matchAbs = want.match(/(.*)\s+\+\-(.+)$/),
|
||||
matchRe = want.match(/^\/(.*)\/$/),
|
||||
// we use this for matching before/after bearing
|
||||
matchBearingListAbs = want.match(/^((\d+)->(\d+))(,(\d+)->(\d+))*\s+\+-(.+)$/),
|
||||
matchIntersectionListAbs = want.match(/^(((((true|false):\d+)\s{0,1})+,{0,1})+;{0,1})+\s+\+-(.+)$/),
|
||||
matchRangeNumbers = want.match(/\d+\+-\d+/);
|
||||
matchBearingListAbs = want.match(/^((\d+)->(\d+))(,(\d+)->(\d+))*\s+\+\-(.+)$/),
|
||||
matchIntersectionListAbs = want.match(/^(((((true|false):\d+)\s{0,1})+,{0,1})+;{0,1})+\s+\+\-(.+)$/),
|
||||
matchRangeNumbers = want.match(/\d+\+\-\d+/);
|
||||
|
||||
function inRange(margin, got, want) {
|
||||
var fromR = parseFloat(want) - margin,
|
||||
@@ -31,12 +31,12 @@ module.exports = {
|
||||
}
|
||||
function parseIntersectionString(str) {
|
||||
return str.split(';')
|
||||
.map((turn_intersections) => turn_intersections
|
||||
.split(',')
|
||||
.map((intersection) => intersection
|
||||
.split(' ')
|
||||
.map((entry_bearing_pair) => entry_bearing_pair
|
||||
.split(':'))));
|
||||
.map((turn_intersections) => turn_intersections
|
||||
.split(',')
|
||||
.map((intersection) => intersection
|
||||
.split(' ')
|
||||
.map((entry_bearing_pair) => entry_bearing_pair
|
||||
.split(':'))));
|
||||
}
|
||||
|
||||
if (got === want) {
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = function () {
|
||||
this.DEFAULT_ENVIRONMENT = Object.assign({STXXLCFG: stxxl_config}, process.env);
|
||||
this.DEFAULT_PROFILE = 'bicycle';
|
||||
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.OSM_USER = 'osrm';
|
||||
this.OSM_UID = 1;
|
||||
@@ -80,7 +80,7 @@ module.exports = function () {
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
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) => {
|
||||
if (exists)
|
||||
|
||||
@@ -115,7 +115,7 @@ module.exports = function () {
|
||||
|
||||
if (headers.has('weight')) {
|
||||
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)'));
|
||||
got.weight = instructions ? util.format('%d', weight) : '';
|
||||
} else {
|
||||
@@ -151,7 +151,7 @@ module.exports = function () {
|
||||
if (headers.has('locations')){
|
||||
got.locations = (locations || '').trim();
|
||||
}
|
||||
/*
|
||||
/*
|
||||
if (headers.has('approaches')){
|
||||
got.approaches = (approaches || '').trim();
|
||||
}*/
|
||||
|
||||
@@ -5,49 +5,21 @@ Feature: Basic Distance Matrix
|
||||
Background:
|
||||
Given the profile "testbot"
|
||||
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
|
||||
"""
|
||||
a b c
|
||||
d e f
|
||||
a b
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| abc |
|
||||
| def |
|
||||
| ad |
|
||||
| be |
|
||||
| cf |
|
||||
| ab |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | e | f |
|
||||
| a | 0 | 100.1 | 199.5 | 299.5 |
|
||||
| b | 100.1 | 0 | 99.4 | 199.5 |
|
||||
| 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 |
|
||||
| | a | b |
|
||||
| a | 0 | 100+-1 |
|
||||
| b | 100+-1 | 0 |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix of minimal network with toll exclude
|
||||
Given the query options
|
||||
@@ -67,11 +39,11 @@ Feature: Basic Distance Matrix
|
||||
| bd | motorway | yes | not drivable for exclude=toll and exclude=motorway,toll |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 100.1 | | |
|
||||
| b | 100.1 | 0 | | |
|
||||
| c | | | 0 | 100.1 |
|
||||
| d | | | 100.1 | 0 |
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 100+-1 | | |
|
||||
| b | 100+-1 | 0 | | |
|
||||
| c | | | 0 | 100+-1 |
|
||||
| d | | | 100+-1 | 0 |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix of minimal network with motorway exclude
|
||||
Given the query options
|
||||
@@ -91,8 +63,8 @@ Feature: Basic Distance Matrix
|
||||
| bd | residential | |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 298.9 | 99.4 | 199.5 |
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 300+-2 | 100+-2 | 200+-2 |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix of minimal network disconnected motorway exclude
|
||||
Given the query options
|
||||
@@ -112,8 +84,8 @@ Feature: Basic Distance Matrix
|
||||
| efgh | residential | |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | e |
|
||||
| a | 0 | 50.1 | |
|
||||
| | a | b | e |
|
||||
| a | 0 | 50+-1 | |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix of minimal network with motorway and toll excludes
|
||||
Given the query options
|
||||
@@ -134,7 +106,7 @@ Feature: Basic Distance Matrix
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | e | g |
|
||||
| a | 0 | 100.1 | | |
|
||||
| a | 0 | 100+-1 | | |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix with different way speeds
|
||||
Given the node map
|
||||
@@ -149,22 +121,22 @@ Feature: Basic Distance Matrix
|
||||
| cd | tertiary |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 100.1 | 200.1 | 300.2 |
|
||||
| b | 100.1 | 0 | 100.1 | 200.1 |
|
||||
| c | 200.1 | 100.1 | 0 | 100.1 |
|
||||
| d | 300.2 | 200.1 | 100.1 | 0 |
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
|
||||
| b | 100+-1 | 0 | 100+-1 | 200+-1 |
|
||||
| c | 200+-1 | 100+-1 | 0 | 100+-1 |
|
||||
| d | 300+-1 | 200+-1 | 100+-1 | 0 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 100.1 | 200.1 | 300.2 |
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| b | 100.1 |
|
||||
| c | 200.1 |
|
||||
| d | 300.2 |
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| b | 100+-1 |
|
||||
| c | 200+-1 |
|
||||
| d | 300+-1 |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix of small grid
|
||||
Given the node map
|
||||
@@ -182,11 +154,11 @@ Feature: Basic Distance Matrix
|
||||
| cf |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | e | f |
|
||||
| a | 0 | 100.1 | 199.5 | 299.5 |
|
||||
| b | 100.1 | 0 | 99.4 | 199.5 |
|
||||
| e | 199.5 | 99.4 | 0 | 100.1 |
|
||||
| f | 299.5 | 199.5 | 100.1 | 0 |
|
||||
| | a | b | e | f |
|
||||
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
|
||||
| b | 100+-1 | 0 | 100+-1 | 200+-1 |
|
||||
| e | 200+-1 | 100+-1 | 0 | 100+-1 |
|
||||
| f | 300+-1 | 200+-1 | 100+-1 | 0 |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix of network with unroutable parts
|
||||
Given the node map
|
||||
@@ -200,7 +172,7 @@ Feature: Basic Distance Matrix
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b |
|
||||
| a | 0 | 100.1 |
|
||||
| a | 0 | 100+-1 |
|
||||
| b | | 0 |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix of network with oneways
|
||||
@@ -217,11 +189,11 @@ Feature: Basic Distance Matrix
|
||||
| by | |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | x | y | d | e |
|
||||
| x | 0 | 300.2 | 399.6 | 299.5 |
|
||||
| y | 499 | 0 | 299.5 | 199.5 |
|
||||
| d | 199.5 | 299.5 | 0 | 298.9 |
|
||||
| e | 299.5 | 399.6 | 100.1 | 0 |
|
||||
| | x | y | d | e |
|
||||
| x | 0 | 300+-2 | 400+-2 | 300+-2 |
|
||||
| y | 500+-2 | 0 | 300+-2 | 200+-2 |
|
||||
| d | 200+-2 | 300+-2 | 0 | 300+-2 |
|
||||
| e | 300+-2 | 400+-2 | 100+-2 | 0 |
|
||||
|
||||
Scenario: Testbot - Rectangular travel distance matrix
|
||||
Given the node map
|
||||
@@ -240,53 +212,53 @@ Feature: Basic Distance Matrix
|
||||
|
||||
When I route I should get
|
||||
| from | to | distance |
|
||||
| e | a | 200m |
|
||||
| e | b | 100m |
|
||||
| f | a | 299.9m |
|
||||
| f | b | 200m |
|
||||
| e | a | 200m +- 1 |
|
||||
| e | b | 100m +- 1 |
|
||||
| f | a | 300m +- 1 |
|
||||
| f | b | 200m +- 1 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | 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
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| b | 100.1 |
|
||||
| e | 199.5 |
|
||||
| f | 299.5 |
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| b | 100+-1 |
|
||||
| e | 200+-1 |
|
||||
| f | 300+-1 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | e | f |
|
||||
| a | 0 | 100.1 | 199.5 | 299.5 |
|
||||
| b | 100.1 | 0 | 99.4 | 199.5 |
|
||||
| | a | b | e | f |
|
||||
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
|
||||
| b | 100+-1 | 0 | 100+-1 | 200+-1 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b |
|
||||
| a | 0 | 100.1 |
|
||||
| b | 100.1 | 0 |
|
||||
| e | 199.5 | 99.4 |
|
||||
| f | 299.5 | 199.5 |
|
||||
| | a | b |
|
||||
| a | 0 | 100+-1 |
|
||||
| b | 100+-1 | 0 |
|
||||
| e | 200+-1 | 100+-1 |
|
||||
| f | 300+-1 | 200+-1 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | e | f |
|
||||
| a | 0 | 100.1 | 199.5 | 299.5 |
|
||||
| b | 100.1 | 0 | 99.4 | 199.5 |
|
||||
| e | 199.5 | 99.4 | 0 | 100.1 |
|
||||
| | a | b | e | f |
|
||||
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
|
||||
| b | 100+-1 | 0 | 100+-1 | 200+-1 |
|
||||
| e | 200+-1 | 100+-1 | 0 | 100+-1 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | e |
|
||||
| a | 0 | 100.1 | 199.5 |
|
||||
| b | 100.1 | 0 | 99.4 |
|
||||
| e | 199.5 | 99.4 | 0 |
|
||||
| f | 299.5 | 199.5 | 100.1 |
|
||||
| | a | b | e |
|
||||
| a | 0 | 100+-1 | 200+-1 |
|
||||
| b | 100+-1 | 0 | 100+-1 |
|
||||
| e | 200+-1 | 100+-1 | 0 |
|
||||
| f | 300+-1 | 200+-1 | 100+-1 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | e | f |
|
||||
| a | 0 | 100.1 | 199.5 | 299.5 |
|
||||
| b | 100.1 | 0 | 99.4 | 199.5 |
|
||||
| e | 199.5 | 99.4 | 0 | 100.1 |
|
||||
| f | 299.5 | 199.5 | 100.1 | 0 |
|
||||
| | a | b | e | f |
|
||||
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
|
||||
| b | 100+-1 | 0 | 100+-1 | 200+-1 |
|
||||
| e | 200+-1 | 100+-1 | 0 | 100+-1 |
|
||||
| f | 300+-1 | 200+-1 | 100+-1 | 0 |
|
||||
|
||||
Scenario: Testbot - Travel distance 3x2 matrix
|
||||
Given the node map
|
||||
@@ -305,9 +277,9 @@ Feature: Basic Distance Matrix
|
||||
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | b | e | f |
|
||||
| a | 100.1 | 199.5 | 299.5 |
|
||||
| b | 0 | 99.4 | 199.5 |
|
||||
| | b | e | f |
|
||||
| a | 100+-1 | 200+-1 | 300+-1 |
|
||||
| b | 0 | 100+-1 | 200+-1 |
|
||||
|
||||
Scenario: Testbot - All coordinates are from same small component
|
||||
Given a grid size of 300 meters
|
||||
@@ -327,9 +299,9 @@ Feature: Basic Distance Matrix
|
||||
| fg |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | f | g |
|
||||
| f | 0 | 298.2 |
|
||||
| g | 298.2 | 0 |
|
||||
| | f | g |
|
||||
| f | 0 | 300+-2 |
|
||||
| g | 300+-2 | 0 |
|
||||
|
||||
Scenario: Testbot - Coordinates are from different small component and snap to big CC
|
||||
Given a grid size of 300 meters
|
||||
@@ -361,11 +333,11 @@ Feature: Basic Distance Matrix
|
||||
| i | h | 300m |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | f | g | h | i |
|
||||
| f | 0 | 298.2 | 0 | 298.2 |
|
||||
| g | 298.2 | 0 | 298.2 | 0 |
|
||||
| h | 0 | 298.2 | 0 | 298.2 |
|
||||
| i | 298.2 | 0 | 298.2 | 0 |
|
||||
| | f | g | h | i |
|
||||
| f | 0 | 300+-2 | 0 | 300+-2 |
|
||||
| g | 300+-2 | 0 | 300+-2 | 0 |
|
||||
| h | 0 | 300+-2 | 0 | 300+-2 |
|
||||
| i | 300+-2 | 0 | 300+-2 | 0 |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix with loops
|
||||
Given the node map
|
||||
@@ -382,11 +354,11 @@ Feature: Basic Distance Matrix
|
||||
| da | yes |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | 1 | 2 | 3 | 4 |
|
||||
| 1 | 0 | 100.1 | 399.6 | 499.7 |
|
||||
| 2 | 699.1 | 0 | 299.5 | 399.6 |
|
||||
| 3 | 399.6 | 499.7 | 0 | 100.1 |
|
||||
| 4 | 299.5 | 399.6 | 699.1 | 0 |
|
||||
| | 1 | 2 | 3 | 4 |
|
||||
| 1 | 0 | 100+-1 | 400+-1 | 500+-1 |
|
||||
| 2 | 700+-1 | 0 | 300+-1 | 400+-1 |
|
||||
| 3 | 400+-1 | 500+-1 | 0 | 100+-1 |
|
||||
| 4 | 300+-1 | 400+-1 | 700+-1 | 0 |
|
||||
|
||||
|
||||
Scenario: Testbot - Travel distance matrix based on segment durations
|
||||
@@ -423,12 +395,12 @@ Feature: Basic Distance Matrix
|
||||
| ce |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | c | d | e |
|
||||
| a | 0 | 100.1 | 200.1 | 300.2 | 398.9 |
|
||||
| b | 100.1 | 0 | 100.1 | 200.1 | 298.9 |
|
||||
| c | 200.1 | 100.1 | 0 | 100.1 | 198.8 |
|
||||
| d | 300.2 | 200.1 | 100.1 | 0 | 298.9 |
|
||||
| e | 398.9 | 298.9 | 198.8 | 298.9 | 0 |
|
||||
| | a | b | c | d | e |
|
||||
| a | 0 | 100+-2 | 200+-2 | 300+-2 | 400+-2 |
|
||||
| b | 100+-2 | 0 | 100+-2 | 200+-2 | 300+-2 |
|
||||
| c | 200+-2 | 100+-2 | 0 | 100+-2 | 200+-2 |
|
||||
| d | 300+-2 | 200+-2 | 100+-2 | 0 | 300+-2 |
|
||||
| e | 400+-2 | 300+-2 | 200+-2 | 300+-2 | 0 |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix for alternative loop paths
|
||||
Given the profile file
|
||||
@@ -467,26 +439,26 @@ Feature: Basic Distance Matrix
|
||||
| ca | yes |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|
||||
| 1 | 0 | 1096.7 | 298.9 | 199.5 | 598.4 | 498.3 | 897.3 | 797.9 |
|
||||
| 2 | 100.1 | 0 | 398.9 | 299.5 | 698.5 | 598.4 | 997.3 | 897.9 |
|
||||
| 3 | 897.9 | 797.9 | 0 | 1097.4 | 299.5 | 199.5 | 598.4 | 499 |
|
||||
| 4 | 997.3 | 897.3 | 99.4 | 0 | 398.9 | 298.9 | 697.8 | 598.4 |
|
||||
| 5 | 598.4 | 498.3 | 897.3 | 797.9 | 0 | 1096.7 | 298.9 | 199.5 |
|
||||
| 6 | 698.5 | 598.4 | 997.3 | 897.9 | 100.1 | 0 | 398.9 | 299.5 |
|
||||
| 7 | 299.5 | 199.5 | 598.4 | 499 | 897.9 | 797.9 | 0 | 1097.4 |
|
||||
| 8 | 398.9 | 298.9 | 697.8 | 598.4 | 997.3 | 897.3 | 99.4 | 0 |
|
||||
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|
||||
| 1 | 0 | 1100+-5 | 300+-5 | 200+-5 | 600+-5 | 500+-5 | 900+-5 | 800+-5 |
|
||||
| 2 | 100+-5 | 0 | 400+-5 | 300+-5 | 700+-5 | 600+-5 | 1000+-5 | 900+-5 |
|
||||
| 3 | 900+-5 | 800+-5 | 0 | 1100+-5 | 300+-5 | 200+-5 | 600+-5 | 500+-5 |
|
||||
| 4 | 1000+-5 | 900+-5 | 100+-5 | 0 | 400+-5 | 300+-5 | 700+-5 | 600+-5 |
|
||||
| 5 | 600+-5 | 500+-5 | 900+-5 | 800+-5 | 0 | 1100+-5 | 300+-5 | 200+-5 |
|
||||
| 6 | 700+-5 | 600+-5 | 1000+-5 | 900+-5 | 100+-5 | 0 | 400+-5 | 300+-5 |
|
||||
| 7 | 300+-5 | 200+-5 | 600+-5 | 500+-5 | 900+-5 | 800+-5 | 0 | 1100+-5 |
|
||||
| 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
|
||||
| | 1 |
|
||||
| 1 | 0 |
|
||||
| 2 | 100.1 |
|
||||
| 3 | 897.9 |
|
||||
| 4 | 997.3 |
|
||||
| 5 | 598.4 |
|
||||
| 6 | 698.5 |
|
||||
| 7 | 299.5 |
|
||||
| 8 | 398.9 |
|
||||
| | 1 |
|
||||
| 1 | 0 |
|
||||
| 2 | 100+-5 |
|
||||
| 3 | 900+-5 |
|
||||
| 4 | 1000+-5 |
|
||||
| 5 | 600+-5 |
|
||||
| 6 | 700+-5 |
|
||||
| 7 | 300+-5 |
|
||||
| 8 | 400+-5 |
|
||||
|
||||
Scenario: Testbot - Travel distance matrix with ties
|
||||
Given the node map
|
||||
@@ -508,26 +480,26 @@ Feature: Basic Distance Matrix
|
||||
| a | c | ac,ac | 200m | 20s | 20 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | distance |
|
||||
| a | b | ab,ab | 450m |
|
||||
| a | c | ac,ac | 200m |
|
||||
| a | d | ac,dc,dc | 499.9m |
|
||||
| from | to | route | distance |
|
||||
| a | b | ab,ab | 450m |
|
||||
| a | c | ac,ac | 200m |
|
||||
| a | d | ac,dc,dc | 500m +- 1 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 450.3 | 198.8 | 499 |
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 450+-2 | 200+-2 | 500+-2 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| b | 450.3 |
|
||||
| c | 198.8 |
|
||||
| d | 499 |
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| b | 450+-2 |
|
||||
| c | 200+-2 |
|
||||
| d | 500+-2 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | c |
|
||||
| a | 0 | 198.8 |
|
||||
| c | 198.8 | 0 |
|
||||
| | a | c |
|
||||
| a | 0 | 200+-2 |
|
||||
| c | 200+-2 | 0 |
|
||||
|
||||
|
||||
# Check rounding errors
|
||||
@@ -543,8 +515,8 @@ Feature: Basic Distance Matrix
|
||||
| abcd |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 1000.7 | 2001.4 | 3002.1 |
|
||||
| | a | b | c | d |
|
||||
| a | 0 | 1000+-3 | 2000+-3 | 3000+-3 |
|
||||
|
||||
|
||||
Scenario: Testbot - OneToMany vs ManyToOne
|
||||
@@ -588,138 +560,10 @@ Feature: Basic Distance Matrix
|
||||
| fd | |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | b | c | d | e | f |
|
||||
| a | 0 | 100.1 | 300.2 | 650.5 | 1930.6 | 1533 |
|
||||
| b | 759 | 0 | 200.1 | 550.4 | 1830.5 | 1432.9 |
|
||||
| c | 558.8 | 658.9 | 0 | 350.3 | 1630.4 | 1232.8 |
|
||||
| d | 1478.9 | 1579 | 1779.1 | 0 | 1280.1 | 882.5 |
|
||||
| e | 198.8 | 298.9 | 499 | 710.3 | 0 | 1592.8 |
|
||||
| f | 596.4 | 696.5 | 896.6 | 1107.9 | 397.6 | 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 |
|
||||
| | a | b | c | d | e | f |
|
||||
| a | 0 | 100+-1 | 300+-1 | 650+-1 | 1930+-1 | 1533+-1 |
|
||||
| b | 760+-1 | 0 | 200+-1 | 550+-1 | 1830+-1 | 1433+-1 |
|
||||
| c | 560+-2 | 660+-2 | 0 | 350+-1 | 1630+-1 | 1233+-1 |
|
||||
| d | 1480+-2 | 1580+-1 | 1780+-1 | 0 | 1280+-1 | 883+-1 |
|
||||
| e | 200+-2 | 300+-2 | 500+-1 | 710+-1 | 0 | 1593+-1 |
|
||||
| f | 597+-1 | 696+-1 | 896+-1 | 1108+-1 | 400+-3 | 0 |
|
||||
|
||||
@@ -510,268 +510,3 @@ Feature: Basic Duration Matrix
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| 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 |
|
||||
|
||||
@@ -38,15 +38,15 @@ Feature: Multi level routing
|
||||
Scenario: Testbot - Multi level routing
|
||||
Given the node map
|
||||
"""
|
||||
a────b e─────f
|
||||
\ │ │ /
|
||||
a───b e───f
|
||||
│ │ │ │
|
||||
d───c h───g
|
||||
╲ ╱
|
||||
╳
|
||||
╱ ╲
|
||||
i───j m───n
|
||||
/ │ │ \
|
||||
l─────k───p─────o
|
||||
│ │ │ │
|
||||
l───k───p───o
|
||||
"""
|
||||
|
||||
And the nodes
|
||||
@@ -67,76 +67,78 @@ Feature: Multi level routing
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | time |
|
||||
| a | b | abcda,abcda | 25s |
|
||||
| a | f | abcda,cm,mnopm,kp,ijkli,hj,efghe,efghe | 239.2s |
|
||||
| a | l | abcda,cm,mnopm,kp,ijkli,ijkli | 157.1s |
|
||||
| a | o | abcda,cm,mnopm,mnopm,mnopm | 137.1s |
|
||||
| f | l | efghe,hj,ijkli,ijkli | 136.7s |
|
||||
| f | o | efghe,hj,ijkli,kp,mnopm,mnopm | 162.1s |
|
||||
| l | o | ijkli,kp,mnopm,mnopm | 80s |
|
||||
| a | b | abcda,abcda | 20s |
|
||||
| a | f | abcda,cm,mnopm,kp,ijkli,hj,efghe,efghe | 229.4s |
|
||||
| a | l | abcda,cm,mnopm,kp,ijkli,ijkli | 144.7s |
|
||||
| a | o | abcda,cm,mnopm,mnopm,mnopm | 124.7s |
|
||||
| f | l | efghe,hj,ijkli,ijkli,ijkli | 124.7s |
|
||||
| f | o | efghe,hj,ijkli,kp,mnopm,mnopm | 144.7s |
|
||||
| l | o | ijkli,kp,mnopm,mnopm | 60s |
|
||||
| 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
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 239.2 | 157.1 | 137.1 |
|
||||
| f | 239.2 | 0 | 136.7 | 162.1 |
|
||||
| l | 157.1 | 136.7 | 0 | 80 |
|
||||
| o | 137.1 | 162.1 | 80 | 0 |
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 229.4 | 144.7 | 124.7 |
|
||||
| f | 229.4 | 0 | 124.7 | 144.7 |
|
||||
| l | 144.7 | 124.7 | 0 | 60 |
|
||||
| o | 124.7 | 144.7 | 60 | 0 |
|
||||
|
||||
When I request a travel time matrix I should get
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 239.2 | 157.1 | 137.1 |
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 229.4 | 144.7 | 124.7 |
|
||||
|
||||
When I request a travel time matrix I should get
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| f | 239.2 |
|
||||
| l | 157.1 |
|
||||
| o | 137.1 |
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| f | 229.4 |
|
||||
| l | 144.7 |
|
||||
| o | 124.7 |
|
||||
|
||||
When I request a travel time matrix I should get
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 239.2 | 157.1 | 137.1 |
|
||||
| o | 137.1 | 162.1 | 80 | 0 |
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 229.4 | 144.7 | 124.7 |
|
||||
| o | 124.7 | 144.7 | 60 | 0 |
|
||||
|
||||
When I request a travel time matrix I should get
|
||||
| | a | o |
|
||||
| a | 0 | 137.1 |
|
||||
| f | 239.2 | 162.1 |
|
||||
| l | 157.1 | 80 |
|
||||
| o | 137.1 | 0 |
|
||||
| a | 0 | 124.7 |
|
||||
| f | 229.4 | 144.7 |
|
||||
| l | 144.7 | 60 |
|
||||
| o | 124.7 | 0 |
|
||||
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 2383.7 | 1566.9 | 1366.8 |
|
||||
| f | 2383.7 | 0 | 1293.3 | 1617.3 |
|
||||
| l | 1566.9 | 1293.3 | 0 | 800.5 |
|
||||
| o | 1366.8 | 1617.3 | 800.5 | 0 |
|
||||
| | a | f | l | o |
|
||||
| a | 0+-2 | 2287+-2 | 1443+-2 | 1243+-2 |
|
||||
| f | 2284+-2 | 0+-2 | 1241+-2 | 1443+-2 |
|
||||
| l | 1443+-2 | 1244+-2 | 0+-2 | 600+-2 |
|
||||
| o | 1243+-2 | 1444+-2 | 600+-2 | 0+-2 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 2383.7 | 1566.9 | 1366.8 |
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 2287.2+-2 | 1443+-2 | 1243+-2 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| f | 2383.7 |
|
||||
| l | 1566.9 |
|
||||
| o | 1366.8 |
|
||||
| | a |
|
||||
| a | 0 |
|
||||
| f | 2284.5+-2 |
|
||||
| l | 1443.1 |
|
||||
| o | 1243 |
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 2383.7 | 1566.9 | 1366.8 |
|
||||
| f | 2383.7 | 0 | 1293.3 | 1617.3 |
|
||||
| | a | f | l | o |
|
||||
| a | 0 | 2287+-2 | 1443+-2 | 1243+-2 |
|
||||
| o | 1243 | 1444+-2 | 600+-2 | 0+-2 |
|
||||
|
||||
|
||||
When I request a travel distance matrix I should get
|
||||
| | a | o |
|
||||
| a | 0 | 1366.8 |
|
||||
| f | 2383.7 | 1617.3 |
|
||||
| l | 1566.9 | 800.5 |
|
||||
| o | 1366.8 | 0 |
|
||||
| | a | o |
|
||||
| a | 0+-2 | 1243+-2 |
|
||||
| f | 2284+-2 | 1443+-2 |
|
||||
| l | 1443+-2 | 600+-2 |
|
||||
| o | 1243+-2 | 0+-2 |
|
||||
|
||||
|
||||
|
||||
Scenario: Testbot - Multi level routing: horizontal road
|
||||
Given the node map
|
||||
|
||||
@@ -182,4 +182,4 @@ Feature: Snap start/end point to the nearest way
|
||||
| x | m | xe,xe |
|
||||
| x | n | xf,xf |
|
||||
| x | o | xg,xg |
|
||||
| x | p | xh,xh |
|
||||
| x | p | xh,xh |
|
||||
|
||||
@@ -72,8 +72,14 @@ struct ContractorConfig final : storage::IOConfig
|
||||
// The remaining vertices form the core of the hierarchy
|
||||
//(e.g. 0.8 contracts 80 percent of the hierarchy, leaving a core of 20%)
|
||||
double core_factor;
|
||||
|
||||
// Whether to store distances for CH edges in addition to duration/weight
|
||||
// Defaults to false. Setting to true will require more storage/memory,
|
||||
// but avoids the need for path unpacking to learn the distance of a CH
|
||||
// route (useful for faster distance results in table queries)
|
||||
bool cache_distances;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace contractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // EXTRACTOR_OPTIONS_HPP
|
||||
|
||||
@@ -77,7 +77,7 @@ struct QueryEdge
|
||||
data.distance == right.data.distance);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace contractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // QUERYEDGE_HPP
|
||||
|
||||
@@ -22,7 +22,6 @@ class CellCustomizer
|
||||
{
|
||||
bool from_clique;
|
||||
EdgeDuration duration;
|
||||
EdgeDistance distance;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -61,7 +60,7 @@ class CellCustomizer
|
||||
}
|
||||
}
|
||||
heap.Clear();
|
||||
heap.Insert(source, 0, {false, 0, 0});
|
||||
heap.Insert(source, 0, {false, 0});
|
||||
|
||||
// explore search space
|
||||
while (!heap.Empty() && !destinations_set.empty())
|
||||
@@ -69,18 +68,8 @@ class CellCustomizer
|
||||
const NodeID node = heap.DeleteMin();
|
||||
const EdgeWeight weight = heap.GetKey(node);
|
||||
const EdgeDuration duration = heap.GetData(node).duration;
|
||||
const EdgeDistance distance = heap.GetData(node).distance;
|
||||
|
||||
RelaxNode(graph,
|
||||
cells,
|
||||
allowed_nodes,
|
||||
metric,
|
||||
heap,
|
||||
level,
|
||||
node,
|
||||
weight,
|
||||
duration,
|
||||
distance);
|
||||
RelaxNode(graph, cells, allowed_nodes, metric, heap, level, node, weight, duration);
|
||||
|
||||
destinations_set.erase(node);
|
||||
}
|
||||
@@ -88,27 +77,21 @@ class CellCustomizer
|
||||
// fill a map of destination nodes to placeholder pointers
|
||||
auto weights = cell.GetOutWeight(source);
|
||||
auto durations = cell.GetOutDuration(source);
|
||||
auto distances = cell.GetOutDistance(source);
|
||||
for (auto &destination : destinations)
|
||||
{
|
||||
BOOST_ASSERT(!weights.empty());
|
||||
BOOST_ASSERT(!durations.empty());
|
||||
BOOST_ASSERT(!distances.empty());
|
||||
|
||||
const bool inserted = heap.WasInserted(destination);
|
||||
weights.front() = inserted ? heap.GetKey(destination) : INVALID_EDGE_WEIGHT;
|
||||
durations.front() =
|
||||
inserted ? heap.GetData(destination).duration : MAXIMAL_EDGE_DURATION;
|
||||
distances.front() =
|
||||
inserted ? heap.GetData(destination).distance : INVALID_EDGE_DISTANCE;
|
||||
|
||||
weights.advance_begin(1);
|
||||
durations.advance_begin(1);
|
||||
distances.advance_begin(1);
|
||||
}
|
||||
BOOST_ASSERT(weights.empty());
|
||||
BOOST_ASSERT(durations.empty());
|
||||
BOOST_ASSERT(distances.empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +128,7 @@ class CellCustomizer
|
||||
LevelID level,
|
||||
NodeID node,
|
||||
EdgeWeight weight,
|
||||
EdgeDuration duration,
|
||||
EdgeDistance distance) const
|
||||
EdgeDuration duration) const
|
||||
{
|
||||
auto first_level = level == 1;
|
||||
BOOST_ASSERT(heap.WasInserted(node));
|
||||
@@ -167,7 +149,6 @@ class CellCustomizer
|
||||
auto subcell = cells.GetCell(metric, level - 1, subcell_id);
|
||||
auto subcell_destination = subcell.GetDestinationNodes().begin();
|
||||
auto subcell_duration = subcell.GetOutDuration(node).begin();
|
||||
auto subcell_distance = subcell.GetOutDistance(node).begin();
|
||||
for (auto subcell_weight : subcell.GetOutWeight(node))
|
||||
{
|
||||
if (subcell_weight != INVALID_EDGE_WEIGHT)
|
||||
@@ -180,24 +161,20 @@ class CellCustomizer
|
||||
|
||||
const EdgeWeight to_weight = weight + subcell_weight;
|
||||
const EdgeDuration to_duration = duration + *subcell_duration;
|
||||
const EdgeDistance to_distance = distance + *subcell_distance;
|
||||
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) <
|
||||
std::tie(heap.GetKey(to),
|
||||
heap.GetData(to).duration,
|
||||
heap.GetData(to).distance))
|
||||
else if (std::tie(to_weight, to_duration) <
|
||||
std::tie(heap.GetKey(to), heap.GetData(to).duration))
|
||||
{
|
||||
heap.DecreaseKey(to, to_weight);
|
||||
heap.GetData(to) = {true, to_duration, to_distance};
|
||||
heap.GetData(to) = {true, to_duration};
|
||||
}
|
||||
}
|
||||
|
||||
++subcell_destination;
|
||||
++subcell_duration;
|
||||
++subcell_distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,18 +195,15 @@ class CellCustomizer
|
||||
{
|
||||
const EdgeWeight to_weight = weight + data.weight;
|
||||
const EdgeDuration to_duration = duration + data.duration;
|
||||
const EdgeDistance to_distance = distance + data.distance;
|
||||
if (!heap.WasInserted(to))
|
||||
{
|
||||
heap.Insert(
|
||||
to, to_weight, {false, duration + data.duration, distance + data.distance});
|
||||
heap.Insert(to, to_weight, {false, duration + data.duration});
|
||||
}
|
||||
else if (std::tie(to_weight, to_duration, to_distance) <
|
||||
std::tie(
|
||||
heap.GetKey(to), heap.GetData(to).duration, heap.GetData(to).distance))
|
||||
else if (std::tie(to_weight, to_duration) <
|
||||
std::tie(heap.GetKey(to), heap.GetData(to).duration))
|
||||
{
|
||||
heap.DecreaseKey(to, to_weight);
|
||||
heap.GetData(to) = {false, to_duration, to_distance};
|
||||
heap.GetData(to) = {false, to_duration};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ template <storage::Ownership Ownership> struct CellMetricImpl
|
||||
|
||||
Vector<EdgeWeight> weights;
|
||||
Vector<EdgeDuration> durations;
|
||||
Vector<EdgeDistance> distances;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,8 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
|
||||
|
||||
MultiLevelGraph(PartitionerGraphT &&graph,
|
||||
Vector<EdgeWeight> node_weights_,
|
||||
Vector<EdgeDuration> node_durations_,
|
||||
Vector<EdgeDistance> node_distances_)
|
||||
: node_weights(std::move(node_weights_)), node_durations(std::move(node_durations_)),
|
||||
node_distances(std::move(node_distances_))
|
||||
Vector<EdgeDuration> node_durations_)
|
||||
: node_weights(std::move(node_weights_)), node_durations(std::move(node_durations_))
|
||||
{
|
||||
util::ViewOrVector<PartitionerGraphT::EdgeArrayEntry, storage::Ownership::Container>
|
||||
original_edge_array;
|
||||
@@ -85,13 +83,11 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
|
||||
Vector<EdgeOffset> node_to_edge_offset_,
|
||||
Vector<EdgeWeight> node_weights_,
|
||||
Vector<EdgeDuration> node_durations_,
|
||||
Vector<EdgeDistance> node_distances_,
|
||||
Vector<bool> is_forward_edge_,
|
||||
Vector<bool> is_backward_edge_)
|
||||
: 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_distances(std::move(node_distances_)), is_forward_edge(is_forward_edge_),
|
||||
is_backward_edge(is_backward_edge_)
|
||||
is_forward_edge(is_forward_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]; }
|
||||
|
||||
EdgeDistance GetNodeDistance(NodeID node) const { return node_distances[node]; }
|
||||
|
||||
bool IsForwardEdge(EdgeID edge) const { return is_forward_edge[edge]; }
|
||||
|
||||
bool IsBackwardEdge(EdgeID edge) const { return is_backward_edge[edge]; }
|
||||
@@ -117,7 +111,6 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
|
||||
protected:
|
||||
Vector<EdgeWeight> node_weights;
|
||||
Vector<EdgeDuration> node_durations;
|
||||
Vector<EdgeDistance> node_distances;
|
||||
Vector<bool> is_forward_edge;
|
||||
Vector<bool> is_backward_edge;
|
||||
};
|
||||
|
||||
@@ -23,7 +23,6 @@ inline void read(storage::tar::FileReader &reader,
|
||||
{
|
||||
storage::serialization::read(reader, name + "/weights", metric.weights);
|
||||
storage::serialization::read(reader, name + "/durations", metric.durations);
|
||||
storage::serialization::read(reader, name + "/distances", metric.distances);
|
||||
}
|
||||
|
||||
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 + "/durations", metric.durations);
|
||||
storage::serialization::write(writer, name + "/distances", metric.distances);
|
||||
}
|
||||
|
||||
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_weights", graph.node_weights);
|
||||
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 + "/is_forward_edge", graph.is_forward_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_weights", graph.node_weights);
|
||||
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 + "/is_forward_edge", graph.is_forward_edge);
|
||||
storage::serialization::write(writer, name + "/is_backward_edge", graph.is_backward_edge);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "engine/api/json_factory.hpp"
|
||||
#include "engine/hint.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/range/algorithm/transform.hpp>
|
||||
@@ -54,8 +53,6 @@ class BaseAPI
|
||||
// TODO: check forward/reverse
|
||||
return json::makeWaypoint(
|
||||
phantom.location,
|
||||
util::coordinate_calculation::fccApproximateDistance(phantom.location,
|
||||
phantom.input_location),
|
||||
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string(),
|
||||
Hint{phantom, facade.GetCheckSum()});
|
||||
}
|
||||
@@ -64,8 +61,6 @@ class BaseAPI
|
||||
// TODO: check forward/reverse
|
||||
return json::makeWaypoint(
|
||||
phantom.location,
|
||||
util::coordinate_calculation::fccApproximateDistance(phantom.location,
|
||||
phantom.input_location),
|
||||
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
|
||||
.to_string());
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace json
|
||||
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
|
||||
@@ -86,14 +86,11 @@ util::json::Object makeRoute(const guidance::Route &route,
|
||||
const char *weight_name);
|
||||
|
||||
// Creates a Waypoint without Hint, see the Hint overload below
|
||||
util::json::Object
|
||||
makeWaypoint(const util::Coordinate &location, const double &distance, std::string name);
|
||||
util::json::Object makeWaypoint(const util::Coordinate location, std::string name);
|
||||
|
||||
// Creates a Waypoint with Hint, see the overload above when Hint is not needed
|
||||
util::json::Object makeWaypoint(const util::Coordinate &location,
|
||||
const double &distance,
|
||||
std::string name,
|
||||
const Hint &hint);
|
||||
util::json::Object
|
||||
makeWaypoint(const util::Coordinate location, std::string name, const Hint &hint);
|
||||
|
||||
util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps);
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ class NearestAPI final : public BaseAPI
|
||||
[this](const PhantomNodeWithDistance &phantom_with_distance) {
|
||||
auto &phantom_node = phantom_with_distance.phantom_node;
|
||||
auto waypoint = MakeWaypoint(phantom_node);
|
||||
waypoint.values["distance"] = phantom_with_distance.distance;
|
||||
|
||||
util::json::Array nodes;
|
||||
|
||||
|
||||
@@ -31,15 +31,6 @@ namespace api
|
||||
class TableAPI final : public BaseAPI
|
||||
{
|
||||
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 ¶meters_)
|
||||
: BaseAPI(facade_, parameters_), parameters(parameters_)
|
||||
{
|
||||
@@ -48,7 +39,6 @@ class TableAPI final : public BaseAPI
|
||||
virtual void
|
||||
MakeResponse(const std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>> &tables,
|
||||
const std::vector<PhantomNode> &phantoms,
|
||||
const std::vector<TableCellRef> &fallback_speed_cells,
|
||||
util::json::Object &response) const
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
if (parameters.fallback_speed != INVALID_FALLBACK_SPEED && parameters.fallback_speed > 0)
|
||||
{
|
||||
response.values["fallback_speed_cells"] = MakeEstimatesTable(fallback_speed_cells);
|
||||
}
|
||||
|
||||
response.values["code"] = "Ok";
|
||||
}
|
||||
|
||||
@@ -178,20 +163,6 @@ class TableAPI final : public BaseAPI
|
||||
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 ¶meters;
|
||||
};
|
||||
|
||||
|
||||
@@ -59,15 +59,6 @@ struct TableParameters : public BaseParameters
|
||||
{
|
||||
std::vector<std::size_t> sources;
|
||||
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
|
||||
{
|
||||
@@ -79,8 +70,6 @@ struct TableParameters : public BaseParameters
|
||||
|
||||
AnnotationsType annotations = AnnotationsType::Duration;
|
||||
|
||||
double scale_factor = 1;
|
||||
|
||||
TableParameters() = default;
|
||||
template <typename... Args>
|
||||
TableParameters(std::vector<std::size_t> sources_,
|
||||
@@ -101,22 +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
|
||||
{
|
||||
if (!BaseParameters::IsValid())
|
||||
@@ -128,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
|
||||
|
||||
// 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(); };
|
||||
|
||||
if (std::any_of(begin(sources), end(sources), not_in_range))
|
||||
@@ -137,12 +117,6 @@ struct TableParameters : public BaseParameters
|
||||
if (std::any_of(begin(destinations), end(destinations), not_in_range))
|
||||
return false;
|
||||
|
||||
if (fallback_speed <= 0)
|
||||
return false;
|
||||
|
||||
if (scale_factor <= 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -78,8 +78,6 @@ template <> class AlgorithmDataFacade<MLD>
|
||||
|
||||
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 IsBackwardEdge(EdgeID edge) const = 0;
|
||||
|
||||
@@ -312,13 +312,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
||||
const float max_distance,
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const override final
|
||||
const Approach approach) const override final
|
||||
{
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
|
||||
return m_geospatial_query->NearestPhantomNodesInRange(
|
||||
input_coordinate, max_distance, approach, use_all_edges);
|
||||
input_coordinate, max_distance, approach);
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
@@ -326,13 +325,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
const float max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range,
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const override final
|
||||
const Approach approach) const override final
|
||||
{
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
|
||||
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>
|
||||
@@ -699,11 +697,6 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
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
|
||||
{
|
||||
return query_graph.IsForwardEdge(node);
|
||||
|
||||
@@ -126,13 +126,11 @@ class BaseDataFacade
|
||||
const float max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range,
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const = 0;
|
||||
const Approach approach) const = 0;
|
||||
virtual std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
||||
const float max_distance,
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const = 0;
|
||||
const Approach approach) const = 0;
|
||||
|
||||
virtual std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <boost/iostreams/device/mapped_file.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -25,7 +24,8 @@ namespace datafacade
|
||||
class MMapMemoryAllocator : public ContiguousBlockAllocator
|
||||
{
|
||||
public:
|
||||
explicit MMapMemoryAllocator(const storage::StorageConfig &config);
|
||||
explicit MMapMemoryAllocator(const storage::StorageConfig &config,
|
||||
const boost::filesystem::path &memory_file);
|
||||
~MMapMemoryAllocator() override final;
|
||||
|
||||
// interface to give access to the datafacades
|
||||
@@ -33,8 +33,8 @@ class MMapMemoryAllocator : public ContiguousBlockAllocator
|
||||
|
||||
private:
|
||||
storage::SharedDataIndex index;
|
||||
std::vector<boost::iostreams::mapped_file> mapped_memory_files;
|
||||
std::string rtree_filename;
|
||||
util::vector_view<char> mapped_memory;
|
||||
boost::iostreams::mapped_file mapped_memory_file;
|
||||
};
|
||||
|
||||
} // namespace datafacade
|
||||
|
||||
@@ -32,8 +32,9 @@ class ExternalProvider final : public DataFacadeProvider<AlgorithmT, FacadeT>
|
||||
public:
|
||||
using Facade = typename DataFacadeProvider<AlgorithmT, FacadeT>::Facade;
|
||||
|
||||
ExternalProvider(const storage::StorageConfig &config)
|
||||
: facade_factory(std::make_shared<datafacade::MMapMemoryAllocator>(config))
|
||||
ExternalProvider(const storage::StorageConfig &config,
|
||||
const boost::filesystem::path &memory_file)
|
||||
: facade_factory(std::make_shared<datafacade::MMapMemoryAllocator>(config, memory_file))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -63,16 +63,12 @@ template <typename Algorithm> class Engine final : public EngineInterface
|
||||
<< "\" with algorithm " << routing_algorithms::name<Algorithm>();
|
||||
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(logWARNING)
|
||||
<< "The 'memory_file' option is DEPRECATED - using direct mmaping instead";
|
||||
}
|
||||
util::Log(logDEBUG) << "Using direct memory mapping with algorithm "
|
||||
<< routing_algorithms::name<Algorithm>();
|
||||
facade_provider = std::make_unique<ExternalProvider<Algorithm>>(config.storage_config);
|
||||
util::Log(logDEBUG) << "Using memory mapped filed at " << config.memory_file
|
||||
<< " with algorithm " << routing_algorithms::name<Algorithm>();
|
||||
facade_provider = std::make_unique<ExternalProvider<Algorithm>>(config.storage_config,
|
||||
config.memory_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -89,7 +89,6 @@ struct EngineConfig final
|
||||
int max_alternatives = 3; // set an arbitrary upper bound; can be adjusted by user
|
||||
bool use_shared_memory = true;
|
||||
boost::filesystem::path memory_file;
|
||||
bool use_mmap = true;
|
||||
Algorithm algorithm = Algorithm::CH;
|
||||
std::string verbosity;
|
||||
std::string dataset_name;
|
||||
|
||||
@@ -53,15 +53,13 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const
|
||||
const Approach approach) const
|
||||
{
|
||||
auto results = rtree.Nearest(
|
||||
input_coordinate,
|
||||
[this, approach, &input_coordinate, use_all_edges](const CandidateSegment &segment) {
|
||||
return boolPairAnd(
|
||||
boolPairAnd(HasValidEdge(segment, use_all_edges), CheckSegmentExclude(segment)),
|
||||
CheckApproach(input_coordinate, segment, approach));
|
||||
[this, approach, &input_coordinate](const CandidateSegment &segment) {
|
||||
return boolPairAnd(boolPairAnd(HasValidEdge(segment), CheckSegmentExclude(segment)),
|
||||
CheckApproach(input_coordinate, segment, approach));
|
||||
},
|
||||
[this, max_distance, input_coordinate](const std::size_t,
|
||||
const CandidateSegment &segment) {
|
||||
@@ -78,17 +76,15 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range,
|
||||
const Approach approach,
|
||||
const bool use_all_edges) const
|
||||
const Approach approach) const
|
||||
{
|
||||
auto results = rtree.Nearest(
|
||||
input_coordinate,
|
||||
[this, approach, &input_coordinate, bearing, bearing_range, use_all_edges](
|
||||
[this, approach, &input_coordinate, bearing, bearing_range](
|
||||
const CandidateSegment &segment) {
|
||||
auto use_direction =
|
||||
boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range),
|
||||
boolPairAnd(HasValidEdge(segment, use_all_edges),
|
||||
CheckSegmentExclude(segment)));
|
||||
boolPairAnd(HasValidEdge(segment), CheckSegmentExclude(segment)));
|
||||
use_direction =
|
||||
boolPairAnd(use_direction, CheckApproach(input_coordinate, segment, approach));
|
||||
return use_direction;
|
||||
@@ -465,7 +461,6 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
EdgeDuration{0});
|
||||
|
||||
EdgeDistance forward_distance_offset = 0;
|
||||
// Sum up the distance from the start to the fwd_segment_position
|
||||
for (auto current = forward_geometry.begin();
|
||||
current < forward_geometry.begin() + data.fwd_segment_position;
|
||||
++current)
|
||||
@@ -495,9 +490,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
EdgeDuration{0});
|
||||
|
||||
EdgeDistance reverse_distance_offset = 0;
|
||||
// Sum up the distance from just after the fwd_segment_position to the end
|
||||
for (auto current = forward_geometry.begin() + data.fwd_segment_position + 1;
|
||||
current != std::prev(forward_geometry.end());
|
||||
for (auto current = forward_geometry.begin();
|
||||
current < forward_geometry.end() - data.fwd_segment_position - 2;
|
||||
++current)
|
||||
{
|
||||
reverse_distance_offset += util::coordinate_calculation::fccApproximateDistance(
|
||||
@@ -634,8 +628,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
* which means that this edge is not currently traversible. If this is the case,
|
||||
* then we shouldn't snap to this edge.
|
||||
*/
|
||||
std::pair<bool, bool> HasValidEdge(const CandidateSegment &segment,
|
||||
const bool use_all_edges = false) const
|
||||
std::pair<bool, bool> HasValidEdge(const CandidateSegment &segment) const
|
||||
{
|
||||
|
||||
bool forward_edge_valid = false;
|
||||
@@ -659,9 +652,6 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace osrm
|
||||
@@ -234,7 +236,7 @@ struct PhantomNodes
|
||||
PhantomNode source_phantom;
|
||||
PhantomNode target_phantom;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
#endif // PHANTOM_NODES_H
|
||||
|
||||
@@ -138,8 +138,7 @@ class BasePlugin
|
||||
std::vector<std::vector<PhantomNodeWithDistance>>
|
||||
GetPhantomNodesInRange(const datafacade::BaseDataFacade &facade,
|
||||
const api::BaseParameters ¶meters,
|
||||
const std::vector<double> radiuses,
|
||||
bool use_all_edges = false) const
|
||||
const std::vector<double> radiuses) const
|
||||
{
|
||||
std::vector<std::vector<PhantomNodeWithDistance>> phantom_nodes(
|
||||
parameters.coordinates.size());
|
||||
@@ -172,13 +171,12 @@ class BasePlugin
|
||||
radiuses[i],
|
||||
parameters.bearings[i]->bearing,
|
||||
parameters.bearings[i]->range,
|
||||
approach,
|
||||
use_all_edges);
|
||||
approach);
|
||||
}
|
||||
else
|
||||
{
|
||||
phantom_nodes[i] = facade.NearestPhantomNodesInRange(
|
||||
parameters.coordinates[i], radiuses[i], approach, use_all_edges);
|
||||
parameters.coordinates[i], radiuses[i], approach);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ class RoutingAlgorithmsInterface
|
||||
ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &source_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
|
||||
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,
|
||||
const std::vector<std::size_t> &source_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
|
||||
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,
|
||||
const std::vector<std::size_t> &_source_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());
|
||||
|
||||
@@ -219,7 +222,8 @@ RoutingAlgorithms<Algorithm>::ManyToManySearch(const std::vector<PhantomNode> &p
|
||||
phantom_nodes,
|
||||
std::move(source_indices),
|
||||
std::move(target_indices),
|
||||
calculate_distance);
|
||||
calculate_distance,
|
||||
calculate_duration);
|
||||
}
|
||||
|
||||
template <typename Algorithm>
|
||||
|
||||
@@ -97,7 +97,8 @@ manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &source_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 engine
|
||||
|
||||
@@ -509,6 +509,90 @@ UnpackedPath search(SearchEngineData<Algorithm> &engine_working_data,
|
||||
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
|
||||
template <typename Algorithm>
|
||||
inline void search(SearchEngineData<Algorithm> &engine_working_data,
|
||||
|
||||
@@ -120,7 +120,7 @@ template <> struct SearchEngineData<routing_algorithms::mld::Algorithm>
|
||||
void InitializeOrClearManyToManyThreadLocalStorage(unsigned number_of_nodes,
|
||||
unsigned number_of_boundary_nodes);
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
#endif // SEARCH_ENGINE_DATA_HPP
|
||||
|
||||
@@ -82,7 +82,7 @@ class CompressedEdgeContainer
|
||||
std::unordered_map<EdgeID, unsigned> m_reverse_edge_id_to_zipped_index_map;
|
||||
std::unique_ptr<SegmentDataContainer> segment_data;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // GEOMETRY_COMPRESSOR_HPP_
|
||||
|
||||
@@ -96,7 +96,7 @@ inline bool EdgeBasedEdge::operator<(const EdgeBasedEdge &other) const
|
||||
return std::tie(source, target, data.weight, unidirectional) <
|
||||
std::tie(other.source, other.target, other.data.weight, other_is_unidirectional);
|
||||
}
|
||||
} // ns extractor
|
||||
} // ns osrm
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* EDGE_BASED_EDGE_HPP */
|
||||
|
||||
@@ -89,9 +89,9 @@ class EdgeBasedGraphFactory
|
||||
// The following get access functions destroy the content in the factory
|
||||
void GetEdgeBasedEdges(util::DeallocatingVector<EdgeBasedEdge> &edges);
|
||||
void GetEdgeBasedNodeSegments(std::vector<EdgeBasedNodeSegment> &nodes);
|
||||
void GetStartPointMarkers(std::vector<bool> &node_is_startpoint);
|
||||
void GetEdgeBasedNodeWeights(std::vector<EdgeWeight> &output_node_weights);
|
||||
void GetEdgeBasedNodeDurations(std::vector<EdgeWeight> &output_node_durations);
|
||||
void GetEdgeBasedNodeDistances(std::vector<EdgeDistance> &output_node_distances);
|
||||
std::uint32_t GetConnectivityChecksum() const;
|
||||
|
||||
std::uint64_t GetNumberOfEdgeBasedNodes() const;
|
||||
@@ -111,11 +111,14 @@ class EdgeBasedGraphFactory
|
||||
std::vector<ConditionalTurnPenalty>
|
||||
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
|
||||
//! edge-based node
|
||||
std::vector<EdgeWeight> m_edge_based_node_weights;
|
||||
std::vector<EdgeDuration> m_edge_based_node_durations;
|
||||
std::vector<EdgeDistance> m_edge_based_node_distances;
|
||||
|
||||
//! list of edge based nodes (compressed segments)
|
||||
std::vector<EdgeBasedNodeSegment> m_edge_based_node_segments;
|
||||
|
||||
@@ -22,9 +22,7 @@ struct EdgeBasedNodeSegment
|
||||
EdgeBasedNodeSegment()
|
||||
: forward_segment_id{SPECIAL_SEGMENTID, false},
|
||||
reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID), v(SPECIAL_NODEID),
|
||||
fwd_segment_position(std::numeric_limits<unsigned short>::max() >>
|
||||
1), // >> 1 because we've only got 15 bits
|
||||
is_startpoint(false)
|
||||
fwd_segment_position(std::numeric_limits<unsigned short>::max())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -32,10 +30,9 @@ struct EdgeBasedNodeSegment
|
||||
const SegmentID reverse_segment_id_,
|
||||
NodeID u,
|
||||
NodeID v,
|
||||
unsigned short fwd_segment_position,
|
||||
bool is_startpoint_)
|
||||
unsigned short fwd_segment_position)
|
||||
: 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);
|
||||
}
|
||||
@@ -44,8 +41,7 @@ struct EdgeBasedNodeSegment
|
||||
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 v; // node-based graph node ID of the target node
|
||||
unsigned short fwd_segment_position : 15; // segment id in a compressed geometry
|
||||
bool is_startpoint : 1;
|
||||
unsigned short fwd_segment_position; // segment id in a compressed geometry
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ class Extractor
|
||||
// output data
|
||||
EdgeBasedNodeDataContainer &edge_based_nodes_container,
|
||||
std::vector<EdgeBasedNodeSegment> &edge_based_node_segments,
|
||||
std::vector<bool> &node_is_startpoint,
|
||||
std::vector<EdgeWeight> &edge_based_node_weights,
|
||||
std::vector<EdgeDuration> &edge_based_node_durations,
|
||||
std::vector<EdgeDistance> &edge_based_node_distances,
|
||||
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
|
||||
std::uint32_t &connectivity_checksum);
|
||||
|
||||
@@ -96,6 +96,7 @@ class Extractor
|
||||
const std::vector<EdgeBasedNodeSegment> &input_node_segments,
|
||||
EdgeBasedNodeDataContainer &nodes_container) const;
|
||||
void BuildRTree(std::vector<EdgeBasedNodeSegment> edge_based_node_segments,
|
||||
std::vector<bool> node_is_startpoint,
|
||||
const std::vector<util::Coordinate> &coordinates);
|
||||
std::shared_ptr<RestrictionMap> LoadRestrictionMap();
|
||||
|
||||
|
||||
@@ -453,8 +453,8 @@ void writeNames(const boost::filesystem::path &path, const NameTableT &table)
|
||||
serialization::write(writer, "/common/names", table);
|
||||
}
|
||||
|
||||
template <typename NodeWeightsVectorT>
|
||||
void readEdgeBasedNodeWeights(const boost::filesystem::path &path, NodeWeightsVectorT &weights)
|
||||
template <typename NodeWeigtsVectorT>
|
||||
void readEdgeBasedNodeWeights(const boost::filesystem::path &path, NodeWeigtsVectorT &weights)
|
||||
{
|
||||
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
|
||||
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);
|
||||
}
|
||||
|
||||
template <typename NodeDistancesVectorT>
|
||||
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>
|
||||
template <typename NodeWeigtsVectorT, typename NodeDurationsVectorT>
|
||||
void readEdgeBasedNodeWeightsDurations(const boost::filesystem::path &path,
|
||||
NodeWeightsVectorT &weights,
|
||||
NodeWeigtsVectorT &weights,
|
||||
NodeDurationsVectorT &durations)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
template <typename NodeWeightsVectorT, typename NodeDurationsVectorT>
|
||||
template <typename NodeWeigtsVectorT, typename NodeDurationsVectorT>
|
||||
void writeEdgeBasedNodeWeightsDurations(const boost::filesystem::path &path,
|
||||
const NodeWeightsVectorT &weights,
|
||||
const NodeWeigtsVectorT &weights,
|
||||
const NodeDurationsVectorT &durations)
|
||||
{
|
||||
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
|
||||
|
||||
@@ -49,7 +49,7 @@ struct ByEdgeOrByMeterValue
|
||||
using value_type = float;
|
||||
value_type value;
|
||||
};
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
struct InternalExtractorEdge
|
||||
{
|
||||
@@ -113,7 +113,7 @@ struct InternalExtractorEdge
|
||||
return v;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // INTERNAL_EXTRACTOR_EDGE_HPP
|
||||
|
||||
@@ -206,7 +206,7 @@ static_assert(sizeof(extractor::NodeBasedEdge) == 32,
|
||||
"bigger than expected. This will influence "
|
||||
"memory consumption.");
|
||||
|
||||
} // ns extractor
|
||||
} // ns osrm
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* NODE_BASED_EDGE_HPP */
|
||||
|
||||
@@ -142,10 +142,6 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
|
||||
if (shared_memory.IsEmpty())
|
||||
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 (path->IsUndefined())
|
||||
@@ -194,18 +190,6 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
|
||||
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)
|
||||
{
|
||||
@@ -1183,70 +1167,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,35 +75,28 @@ template <storage::Ownership Ownership> class CellStorageImpl
|
||||
|
||||
// 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.
|
||||
template <typename WeightValueT, typename DurationValueT, typename DistanceValueT>
|
||||
class CellImpl
|
||||
template <typename WeightValueT, typename DurationValueT> class CellImpl
|
||||
{
|
||||
private:
|
||||
using WeightPtrT = WeightValueT *;
|
||||
using DurationPtrT = DurationValueT *;
|
||||
using DistancePtrT = DistanceValueT *;
|
||||
BoundarySize num_source_nodes;
|
||||
BoundarySize num_destination_nodes;
|
||||
|
||||
WeightPtrT const weights;
|
||||
DurationPtrT const durations;
|
||||
DistancePtrT const distances;
|
||||
const NodeID *const source_boundary;
|
||||
const NodeID *const destination_boundary;
|
||||
|
||||
using RowIterator = WeightPtrT;
|
||||
// Possibly replace with
|
||||
// http://www.boost.org/doc/libs/1_55_0/libs/range/doc/html/range/reference/adaptors/reference/strided.html
|
||||
|
||||
template <typename ValuePtrT>
|
||||
class ColumnIterator : public boost::iterator_facade<ColumnIterator<ValuePtrT>,
|
||||
decltype(*std::declval<ValuePtrT>()),
|
||||
class ColumnIterator : public boost::iterator_facade<ColumnIterator,
|
||||
WeightValueT,
|
||||
boost::random_access_traversal_tag>
|
||||
{
|
||||
|
||||
using ValueT = decltype(*std::declval<ValuePtrT>());
|
||||
typedef boost::iterator_facade<ColumnIterator<ValueT>,
|
||||
ValueT,
|
||||
typedef boost::iterator_facade<ColumnIterator,
|
||||
WeightValueT,
|
||||
boost::random_access_traversal_tag>
|
||||
base_t;
|
||||
|
||||
@@ -115,7 +108,7 @@ template <storage::Ownership Ownership> class CellStorageImpl
|
||||
|
||||
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)
|
||||
{
|
||||
BOOST_ASSERT(begin != nullptr);
|
||||
@@ -133,7 +126,7 @@ template <storage::Ownership Ownership> class CellStorageImpl
|
||||
}
|
||||
|
||||
friend class ::boost::iterator_core_access;
|
||||
ValuePtrT current;
|
||||
WeightPtrT current;
|
||||
const std::size_t stride;
|
||||
};
|
||||
|
||||
@@ -154,13 +147,12 @@ template <storage::Ownership Ownership> class CellStorageImpl
|
||||
auto iter =
|
||||
std::find(destination_boundary, destination_boundary + num_destination_nodes, node);
|
||||
if (iter == destination_boundary + num_destination_nodes)
|
||||
return boost::make_iterator_range(ColumnIterator<ValuePtr>{},
|
||||
ColumnIterator<ValuePtr>{});
|
||||
return boost::make_iterator_range(ColumnIterator{}, ColumnIterator{});
|
||||
|
||||
auto column = std::distance(destination_boundary, iter);
|
||||
auto begin = ColumnIterator<ValuePtr>{ptr + column, num_destination_nodes};
|
||||
auto end = ColumnIterator<ValuePtr>{
|
||||
ptr + column + num_source_nodes * num_destination_nodes, num_destination_nodes};
|
||||
auto begin = ColumnIterator{ptr + column, num_destination_nodes};
|
||||
auto end = ColumnIterator{ptr + column + num_source_nodes * num_destination_nodes,
|
||||
num_destination_nodes};
|
||||
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 GetInDistance(NodeID node) const { return GetInRange(distances, node); }
|
||||
|
||||
auto GetOutDistance(NodeID node) const { return GetOutRange(distances, node); }
|
||||
|
||||
auto GetSourceNodes() const
|
||||
{
|
||||
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,
|
||||
WeightPtrT const all_weights,
|
||||
DurationPtrT const all_durations,
|
||||
DistancePtrT const all_distances,
|
||||
const NodeID *const all_sources,
|
||||
const NodeID *const all_destinations)
|
||||
: num_source_nodes{data.num_source_nodes},
|
||||
num_destination_nodes{data.num_destination_nodes},
|
||||
weights{all_weights + data.value_offset},
|
||||
durations{all_durations + data.value_offset},
|
||||
distances{all_distances + data.value_offset},
|
||||
source_boundary{all_sources + data.source_boundary_offset},
|
||||
destination_boundary{all_destinations + data.destination_boundary_offset}
|
||||
{
|
||||
BOOST_ASSERT(all_weights != nullptr);
|
||||
BOOST_ASSERT(all_durations != nullptr);
|
||||
BOOST_ASSERT(all_distances != nullptr);
|
||||
BOOST_ASSERT(num_source_nodes == 0 || all_sources != 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)
|
||||
: num_source_nodes{data.num_source_nodes},
|
||||
num_destination_nodes{data.num_destination_nodes}, weights{nullptr},
|
||||
durations{nullptr}, distances{nullptr},
|
||||
source_boundary{all_sources + data.source_boundary_offset},
|
||||
durations{nullptr}, source_boundary{all_sources + data.source_boundary_offset},
|
||||
destination_boundary{all_destinations + data.destination_boundary_offset}
|
||||
{
|
||||
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; }
|
||||
|
||||
public:
|
||||
using Cell = CellImpl<EdgeWeight, EdgeDuration, EdgeDistance>;
|
||||
using ConstCell = CellImpl<const EdgeWeight, const EdgeDuration, const EdgeDistance>;
|
||||
using Cell = CellImpl<EdgeWeight, EdgeDuration>;
|
||||
using ConstCell = CellImpl<const EdgeWeight, const EdgeDuration>;
|
||||
|
||||
CellStorageImpl() {}
|
||||
|
||||
@@ -377,7 +361,6 @@ template <storage::Ownership Ownership> class CellStorageImpl
|
||||
|
||||
metric.weights.resize(total_size + 1, INVALID_EDGE_WEIGHT);
|
||||
metric.durations.resize(total_size + 1, MAXIMAL_EDGE_DURATION);
|
||||
metric.distances.resize(total_size + 1, INVALID_EDGE_DISTANCE);
|
||||
|
||||
return metric;
|
||||
}
|
||||
@@ -405,7 +388,6 @@ template <storage::Ownership Ownership> class CellStorageImpl
|
||||
return ConstCell{cells[cell_index],
|
||||
metric.weights.data(),
|
||||
metric.durations.data(),
|
||||
metric.distances.data(),
|
||||
source_boundary.empty() ? nullptr : source_boundary.data(),
|
||||
destination_boundary.empty() ? nullptr : destination_boundary.data()};
|
||||
}
|
||||
@@ -433,7 +415,6 @@ template <storage::Ownership Ownership> class CellStorageImpl
|
||||
return Cell{cells[cell_index],
|
||||
metric.weights.data(),
|
||||
metric.durations.data(),
|
||||
metric.distances.data(),
|
||||
source_boundary.data(),
|
||||
destination_boundary.data()};
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/parallel_reduce.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -198,7 +200,7 @@ inline DynamicEdgeBasedGraph LoadEdgeBasedGraph(const boost::filesystem::path &p
|
||||
return DynamicEdgeBasedGraph(number_of_edge_based_nodes, std::move(tidied), checksum);
|
||||
}
|
||||
|
||||
} // ns partition
|
||||
} // ns osrm
|
||||
} // namespace partitioner
|
||||
} // namespace osrm
|
||||
|
||||
#endif
|
||||
|
||||
@@ -178,8 +178,6 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
||||
qi::rule<Iterator, Signature> base_rule;
|
||||
qi::rule<Iterator, Signature> query_rule;
|
||||
|
||||
qi::real_parser<double, json_policy> double_;
|
||||
|
||||
private:
|
||||
qi::rule<Iterator, Signature> bearings_rule;
|
||||
qi::rule<Iterator, Signature> radiuses_rule;
|
||||
@@ -197,6 +195,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
||||
qi::rule<Iterator, unsigned char()> base64_char;
|
||||
qi::rule<Iterator, std::string()> polyline_chars;
|
||||
qi::rule<Iterator, double()> unlimited_rule;
|
||||
qi::real_parser<double, json_policy> double_;
|
||||
|
||||
qi::symbols<char, engine::Approach> approach_type;
|
||||
};
|
||||
|
||||
@@ -48,28 +48,10 @@ struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature
|
||||
(qi::lit("all") |
|
||||
(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);
|
||||
|
||||
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
|
||||
-('?' > (table_rule(qi::_r1) | base_rule(qi::_r1) | scale_factor_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])) %
|
||||
'&');
|
||||
-('?' > (table_rule(qi::_r1) | base_rule(qi::_r1)) % '&');
|
||||
}
|
||||
|
||||
TableParametersGrammar(qi::rule<Iterator, Signature> &root_rule_) : BaseGrammar(root_rule_)
|
||||
@@ -91,20 +73,13 @@ struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature
|
||||
qi::rule<Iterator, Signature> base_rule;
|
||||
|
||||
private:
|
||||
using json_policy = no_trailing_dot_policy<double, 'j', 's', 'o', 'n'>;
|
||||
|
||||
qi::rule<Iterator, Signature> root_rule;
|
||||
qi::rule<Iterator, Signature> table_rule;
|
||||
qi::rule<Iterator, Signature> sources_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::symbols<char, engine::api::TableParameters::AnnotationsType> annotations;
|
||||
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_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,10 @@ struct Block
|
||||
{
|
||||
std::uint64_t num_entries;
|
||||
std::uint64_t byte_size;
|
||||
std::uint64_t offset;
|
||||
|
||||
Block() : num_entries(0), byte_size(0), offset(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() : num_entries(0), byte_size(0) {}
|
||||
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)
|
||||
{
|
||||
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};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "storage/shared_datatype.hpp"
|
||||
#include "storage/tar.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/function_output_iterator.hpp>
|
||||
#include <boost/iterator/function_input_iterator.hpp>
|
||||
|
||||
@@ -31,37 +30,22 @@ namespace serialization
|
||||
namespace detail
|
||||
{
|
||||
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_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;
|
||||
for (std::size_t bit = 0; bit < count; ++bit)
|
||||
{
|
||||
value |= (data[base_index + bit] ? BlockT{1} : BlockT{0}) << bit;
|
||||
}
|
||||
for (std::size_t bit = 0; bit < count; ++bit, ++index)
|
||||
value = (value << 1) | data[index];
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename T, typename BlockT = unsigned char>
|
||||
inline void
|
||||
unpackBits(T &data, const std::size_t base_index, const std::size_t count, const BlockT value)
|
||||
inline void unpackBits(T &data, std::size_t index, std::size_t count, BlockT value)
|
||||
{
|
||||
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);
|
||||
for (std::size_t bit = 0; bit < count; ++bit)
|
||||
{
|
||||
data[base_index + bit] = value & (BlockT{1} << bit);
|
||||
}
|
||||
const BlockT mask = BlockT{1} << (count - 1);
|
||||
for (std::size_t bit = 0; bit < count; value <<= 1, ++bit, ++index)
|
||||
data[index] = value & mask;
|
||||
}
|
||||
|
||||
template <typename VectorT>
|
||||
@@ -71,16 +55,15 @@ void readBoolVector(tar::FileReader &reader, const std::string &name, VectorT &d
|
||||
data.resize(count);
|
||||
std::uint64_t index = 0;
|
||||
|
||||
using BlockType = std::uint64_t;
|
||||
constexpr std::uint64_t BLOCK_BITS = CHAR_BIT * sizeof(BlockType);
|
||||
constexpr std::uint64_t WORD_BITS = CHAR_BIT * sizeof(std::uint64_t);
|
||||
|
||||
const auto decode = [&](const BlockType block) {
|
||||
auto read_size = std::min<std::size_t>(count - index, BLOCK_BITS);
|
||||
unpackBits<VectorT, BlockType>(data, index, read_size, block);
|
||||
index += BLOCK_BITS;
|
||||
const auto decode = [&](const std::uint64_t block) {
|
||||
auto read_size = std::min<std::size_t>(count - index, WORD_BITS);
|
||||
unpackBits<VectorT, std::uint64_t>(data, index, read_size, block);
|
||||
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>
|
||||
@@ -90,20 +73,19 @@ void writeBoolVector(tar::FileWriter &writer, const std::string &name, const Vec
|
||||
writer.WriteElementCount64(name, count);
|
||||
std::uint64_t index = 0;
|
||||
|
||||
using BlockType = std::uint64_t;
|
||||
constexpr std::uint64_t BLOCK_BITS = CHAR_BIT * sizeof(BlockType);
|
||||
constexpr std::uint64_t WORD_BITS = CHAR_BIT * sizeof(std::uint64_t);
|
||||
|
||||
// FIXME on old boost version the function_input_iterator does not work with lambdas
|
||||
// so we need to wrap it in a function here.
|
||||
const std::function<BlockType()> encode_function = [&]() -> BlockType {
|
||||
auto write_size = std::min<std::size_t>(count - index, BLOCK_BITS);
|
||||
auto packed = packBits<VectorT, BlockType>(data, index, write_size);
|
||||
index += BLOCK_BITS;
|
||||
const std::function<std::uint64_t()> encode_function = [&]() -> std::uint64_t {
|
||||
auto write_size = std::min<std::size_t>(count - index, WORD_BITS);
|
||||
auto packed = packBits<VectorT, std::uint64_t>(data, index, write_size);
|
||||
index += WORD_BITS;
|
||||
return packed;
|
||||
};
|
||||
|
||||
std::uint64_t number_of_blocks = (count + BLOCK_BITS - 1) / BLOCK_BITS;
|
||||
writer.WriteStreaming<BlockType>(
|
||||
std::uint64_t number_of_blocks = (count + WORD_BITS - 1) / WORD_BITS;
|
||||
writer.WriteStreaming<std::uint64_t>(
|
||||
name,
|
||||
boost::make_function_input_iterator(encode_function, boost::infinite()),
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include <boost/function_output_iterator.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace osrm
|
||||
@@ -20,8 +19,8 @@ class SharedDataIndex
|
||||
public:
|
||||
struct AllocatedRegion
|
||||
{
|
||||
void *memory_ptr;
|
||||
std::unique_ptr<BaseDataLayout> layout;
|
||||
char *memory_ptr;
|
||||
DataLayout layout;
|
||||
};
|
||||
|
||||
SharedDataIndex() = default;
|
||||
@@ -30,10 +29,10 @@ class SharedDataIndex
|
||||
// Build mapping from block name to region
|
||||
for (auto index : util::irange<std::uint32_t>(0, regions.size()))
|
||||
{
|
||||
regions[index].layout->List("",
|
||||
boost::make_function_output_iterator([&](const auto &name) {
|
||||
block_to_region[name] = index;
|
||||
}));
|
||||
regions[index].layout.List("",
|
||||
boost::make_function_output_iterator([&](const auto &name) {
|
||||
block_to_region[name] = index;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,44 +40,32 @@ class SharedDataIndex
|
||||
{
|
||||
for (const auto ®ion : regions)
|
||||
{
|
||||
region.layout->List(name_prefix, out);
|
||||
region.layout.List(name_prefix, out);
|
||||
}
|
||||
}
|
||||
|
||||
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 ®ion = 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)
|
||||
{
|
||||
#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 ®ion = 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
|
||||
{
|
||||
const auto ®ion = GetBlockRegion(name);
|
||||
return region.layout->GetBlockEntries(name);
|
||||
return region.layout.GetBlockEntries(name);
|
||||
}
|
||||
|
||||
std::size_t GetBlockSize(const std::string &name) const
|
||||
{
|
||||
const auto ®ion = GetBlockRegion(name);
|
||||
return region.layout->GetBlockSize(name);
|
||||
return region.layout.GetBlockSize(name);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace osrm
|
||||
namespace storage
|
||||
{
|
||||
|
||||
class BaseDataLayout;
|
||||
class DataLayout;
|
||||
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
|
||||
@@ -54,28 +54,44 @@ inline std::string trimName(const std::string &name_prefix, const std::string &n
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
class BaseDataLayout
|
||||
class DataLayout
|
||||
{
|
||||
public:
|
||||
virtual ~BaseDataLayout() = default;
|
||||
DataLayout() : blocks{} {}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
inline std::uint64_t GetBlockSize(const std::string &name) const
|
||||
{
|
||||
return GetBlock(name).byte_size;
|
||||
}
|
||||
inline uint64_t GetBlockSize(const std::string &name) const { return GetBlock(name).byte_size; }
|
||||
|
||||
inline bool HasBlock(const std::string &name) const
|
||||
{
|
||||
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
|
||||
// or all entries in the sub-directory.
|
||||
// '/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;
|
||||
virtual inline std::uint64_t GetSizeOfLayout() const = 0;
|
||||
private:
|
||||
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
|
||||
{
|
||||
auto iter = blocks.find(name);
|
||||
@@ -114,42 +130,10 @@ class BaseDataLayout
|
||||
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
|
||||
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;
|
||||
return ptr = reinterpret_cast<void *>(aligned);
|
||||
}
|
||||
@@ -173,27 +157,7 @@ class ContiguousDataLayout final : public BaseDataLayout
|
||||
}
|
||||
|
||||
static constexpr std::size_t BLOCK_ALIGNMENT = 64;
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
std::map<std::string, Block> blocks;
|
||||
};
|
||||
|
||||
struct SharedRegion
|
||||
|
||||
@@ -35,28 +35,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace storage
|
||||
{
|
||||
|
||||
void populateLayoutFromFile(const boost::filesystem::path &path, storage::BaseDataLayout &layout);
|
||||
|
||||
class Storage
|
||||
{
|
||||
public:
|
||||
Storage(StorageConfig config);
|
||||
|
||||
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 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:
|
||||
StorageConfig config;
|
||||
|
||||
@@ -294,14 +294,11 @@ inline auto make_filtered_cell_metric_view(const SharedDataIndex &index,
|
||||
auto prefix = name + "/exclude/" + std::to_string(exclude_index);
|
||||
auto weights_block_id = prefix + "/weights";
|
||||
auto durations_block_id = prefix + "/durations";
|
||||
auto distances_block_id = prefix + "/distances";
|
||||
|
||||
auto weights = make_vector_view<EdgeWeight>(index, weights_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{
|
||||
std::move(weights), std::move(durations), std::move(distances)};
|
||||
return customizer::CellMetricView{std::move(weights), std::move(durations)};
|
||||
}
|
||||
|
||||
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 durations_block_id = prefix + "/durations";
|
||||
auto distances_block_id = prefix + "/distances";
|
||||
|
||||
auto weights = make_vector_view<EdgeWeight>(index, weights_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{
|
||||
std::move(weights), std::move(durations), std::move(distances)});
|
||||
cell_metric_excludes.push_back(
|
||||
customizer::CellMetricView{std::move(weights), std::move(durations)});
|
||||
}
|
||||
|
||||
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");
|
||||
auto node_weights = make_vector_view<EdgeWeight>(index, name + "/node_weights");
|
||||
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_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_weights),
|
||||
std::move(node_durations),
|
||||
std::move(node_distances),
|
||||
std::move(is_forward_edge),
|
||||
std::move(is_backward_edge));
|
||||
}
|
||||
|
||||
@@ -22,17 +22,11 @@ class Updater
|
||||
std::vector<EdgeWeight> &node_weights,
|
||||
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::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;
|
||||
EdgeID
|
||||
LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
||||
std::vector<EdgeWeight> &node_weights,
|
||||
std::vector<EdgeDuration> &node_durations, // TODO: to be deleted
|
||||
std::uint32_t &connectivity_checksum) const;
|
||||
|
||||
private:
|
||||
UpdaterConfig config;
|
||||
|
||||
+14
-13
@@ -27,7 +27,7 @@ inline std::ostream &operator<<(std::ostream &out, const Coordinate &coordinate)
|
||||
<< toFloating(coordinate.lat) << "}";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
} // namespace util
|
||||
|
||||
namespace engine
|
||||
{
|
||||
@@ -62,8 +62,8 @@ inline std::ostream &operator<<(std::ostream &out, const RouteStep &step)
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace guidance
|
||||
} // namespace engine
|
||||
|
||||
namespace guidance
|
||||
{
|
||||
@@ -76,7 +76,7 @@ inline std::ostream &operator<<(std::ostream &out, const ConnectedRoad &road)
|
||||
<< static_cast<std::int32_t>(road.lane_data_id) << "}";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
} // namespace guidance
|
||||
|
||||
namespace extractor
|
||||
{
|
||||
@@ -95,7 +95,7 @@ inline std::ostream &operator<<(std::ostream &out, const IntersectionViewData &v
|
||||
<< " angle: " << view.angle << " bearing: " << view.perceived_bearing << "}";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
} // namespace intersection
|
||||
|
||||
namespace TurnLaneType
|
||||
{
|
||||
@@ -125,9 +125,9 @@ inline std::ostream &operator<<(std::ostream &out, const Mask lane_type)
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace TurnLaneType
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
namespace std
|
||||
{
|
||||
@@ -147,7 +147,7 @@ inline std::ostream &operator<<(std::ostream &out,
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -186,8 +186,8 @@ inline std::ostream &operator<<(std::ostream &out, const LaneDataVector &turn_la
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace lanes
|
||||
} // namespace guidance
|
||||
|
||||
namespace extractor
|
||||
{
|
||||
@@ -204,7 +204,8 @@ inline std::ostream &operator<<(std::ostream &out, const EdgeBasedEdge &edge)
|
||||
out << "}";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_ENGINE_GUIDANCE_DEBUG_HPP_*/
|
||||
|
||||
@@ -29,7 +29,7 @@ THE SOFTWARE.
|
||||
#include <math.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include "rapidjson/msinttypes/stdint.h"
|
||||
#include "msinttypes/stdint.h"
|
||||
#include <intrin.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
|
||||
+16
-17
@@ -15,14 +15,14 @@ namespace util
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, typename MmapContainerT>
|
||||
util::vector_view<T> mmapFile(const boost::filesystem::path &file, MmapContainerT &mmap_container)
|
||||
template <typename T, typename RegionT>
|
||||
util::vector_view<T> mmapFile(const boost::filesystem::path &file, RegionT ®ion)
|
||||
{
|
||||
try
|
||||
{
|
||||
mmap_container.open(file);
|
||||
std::size_t num_objects = mmap_container.size() / sizeof(T);
|
||||
auto data_ptr = mmap_container.data();
|
||||
region.open(file);
|
||||
std::size_t num_objects = region.size() / sizeof(T);
|
||||
auto data_ptr = region.data();
|
||||
BOOST_ASSERT(reinterpret_cast<uintptr_t>(data_ptr) % alignof(T) == 0);
|
||||
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>
|
||||
util::vector_view<T> mmapFile(const boost::filesystem::path &file,
|
||||
MmapContainerT &mmap_container,
|
||||
const std::size_t size)
|
||||
template <typename T, typename RegionT>
|
||||
util::vector_view<T>
|
||||
mmapFile(const boost::filesystem::path &file, RegionT ®ion, const std::size_t size)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -46,10 +45,10 @@ util::vector_view<T> mmapFile(const boost::filesystem::path &file,
|
||||
params.path = file.string();
|
||||
params.flags = boost::iostreams::mapped_file::readwrite;
|
||||
params.new_file_size = size;
|
||||
mmap_container.open(params);
|
||||
region.open(params);
|
||||
|
||||
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);
|
||||
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>
|
||||
util::vector_view<const T> mmapFile(const boost::filesystem::path &file,
|
||||
boost::iostreams::mapped_file_source &mmap_container)
|
||||
boost::iostreams::mapped_file_source ®ion)
|
||||
{
|
||||
return detail::mmapFile<const T>(file, mmap_container);
|
||||
return detail::mmapFile<const T>(file, region);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::vector_view<T> mmapFile(const boost::filesystem::path &file,
|
||||
boost::iostreams::mapped_file &mmap_container)
|
||||
boost::iostreams::mapped_file ®ion)
|
||||
{
|
||||
return detail::mmapFile<T>(file, mmap_container);
|
||||
return detail::mmapFile<T>(file, region);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::vector_view<T> mmapFile(const boost::filesystem::path &file,
|
||||
boost::iostreams::mapped_file &mmap_container,
|
||||
boost::iostreams::mapped_file ®ion,
|
||||
std::size_t size)
|
||||
{
|
||||
return detail::mmapFile<T>(file, mmap_container, size);
|
||||
return detail::mmapFile<T>(file, region, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +88,12 @@ NodeBasedDynamicGraphFromEdges(NodeID number_of_nodes,
|
||||
output_edge.data.flags = input_edge.flags;
|
||||
output_edge.data.annotation_data = input_edge.annotation_data;
|
||||
|
||||
BOOST_ASSERT(output_edge.data.weight > 0);
|
||||
BOOST_ASSERT(output_edge.data.duration > 0);
|
||||
BOOST_ASSERT(output_edge.data.weight >= 0);
|
||||
BOOST_ASSERT(output_edge.data.duration >= 0);
|
||||
if (output_edge.data.distance <= 0)
|
||||
{
|
||||
std::cout << "output_edge.data.distance " << output_edge.data.distance << std::endl;
|
||||
}
|
||||
BOOST_ASSERT(output_edge.data.distance >= 0);
|
||||
});
|
||||
|
||||
@@ -97,7 +101,7 @@ NodeBasedDynamicGraphFromEdges(NodeID number_of_nodes,
|
||||
|
||||
return NodeBasedDynamicGraph(number_of_nodes, edges_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
#endif // NODE_BASED_GRAPH_HPP
|
||||
|
||||
@@ -48,7 +48,7 @@ struct osm_way_id
|
||||
struct duplicated_node
|
||||
{
|
||||
};
|
||||
}
|
||||
} // namespace tag
|
||||
using OSMNodeID = osrm::Alias<std::uint64_t, tag::osm_node_id>;
|
||||
static_assert(std::is_pod<OSMNodeID>(), "OSMNodeID is not a valid alias");
|
||||
using OSMWayID = osrm::Alias<std::uint64_t, tag::osm_way_id>;
|
||||
@@ -116,7 +116,6 @@ static const EdgeDuration MAXIMAL_EDGE_DURATION = std::numeric_limits<EdgeDurati
|
||||
static const EdgeDistance MAXIMAL_EDGE_DISTANCE = std::numeric_limits<EdgeDistance>::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_FALLBACK_SPEED = std::numeric_limits<double>::max();
|
||||
|
||||
// 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
|
||||
|
||||
@@ -195,10 +195,7 @@ template <> class vector_view<bool>
|
||||
{
|
||||
BOOST_ASSERT_MSG(index < m_size, "invalid size");
|
||||
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;
|
||||
BOOST_ASSERT(WORD_BITS > offset);
|
||||
return m_ptr[bucket] & (static_cast<Word>(1) << offset);
|
||||
}
|
||||
|
||||
@@ -227,23 +224,11 @@ template <> class vector_view<bool>
|
||||
{
|
||||
BOOST_ASSERT(index < m_size);
|
||||
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;
|
||||
BOOST_ASSERT(WORD_BITS > offset);
|
||||
return reference{m_ptr + bucket, static_cast<Word>(1) << offset};
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
Generated
+2899
-6734
File diff suppressed because it is too large
Load Diff
+7
-7
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "osrm",
|
||||
"version": "5.21.0",
|
||||
"version": "5.20.0-alpha.2",
|
||||
"private": false,
|
||||
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
|
||||
"dependencies": {
|
||||
"mkdirp": "^0.5.1",
|
||||
"nan": "^2.11.1",
|
||||
"nan": "^2.6.2",
|
||||
"node-cmake": "^2.3.2",
|
||||
"node-pre-gyp": "^0.12.0",
|
||||
"node-pre-gyp": "^0.6.36",
|
||||
"rimraf": "^2.5.4"
|
||||
},
|
||||
"browserify": {
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"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",
|
||||
"clean": "rm -rf test/cache",
|
||||
"docs": "./scripts/build_api_docs.sh",
|
||||
"install": "node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh",
|
||||
@@ -47,14 +47,14 @@
|
||||
"csv-stringify": "^3.0.0",
|
||||
"cucumber": "^1.2.1",
|
||||
"d3-queue": "^2.0.3",
|
||||
"docbox": "^1.0.11",
|
||||
"docbox": "^1.0.6",
|
||||
"documentation": "^4.0.0-rc.1",
|
||||
"eslint": "^5.10.0",
|
||||
"eslint": "^2.4.0",
|
||||
"faucet": "^0.0.1",
|
||||
"jsonpath": "^1.0.0",
|
||||
"node-timeout": "0.0.4",
|
||||
"polyline": "^0.2.0",
|
||||
"request": "^2.88.0",
|
||||
"request": "^2.69.0",
|
||||
"tape": "^4.7.0",
|
||||
"turf": "^3.0.14",
|
||||
"xmlbuilder": "^4.2.1"
|
||||
|
||||
+17
-4
@@ -7,7 +7,6 @@ Sequence = require('lib/sequence')
|
||||
Handlers = require("lib/way_handlers")
|
||||
find_access_tag = require("lib/access").find_access_tag
|
||||
limit = require("lib/maxspeed").limit
|
||||
Measure = require("lib/measure")
|
||||
|
||||
function setup()
|
||||
local default_speed = 15
|
||||
@@ -207,6 +206,20 @@ function setup()
|
||||
}
|
||||
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)
|
||||
-- parse access and barrier tags
|
||||
local highway = node:get_value_by_key("highway")
|
||||
@@ -263,9 +276,9 @@ function handle_bicycle_tags(profile,way,result,data)
|
||||
|
||||
-- other tags
|
||||
data.junction = way:get_value_by_key("junction")
|
||||
data.maxspeed = Measure.get_max_speed(way:get_value_by_key ("maxspeed")) or 0
|
||||
data.maxspeed_forward = Measure.get_max_speed(way:get_value_by_key("maxspeed:forward")) or 0
|
||||
data.maxspeed_backward = Measure.get_max_speed(way:get_value_by_key("maxspeed:backward")) or 0
|
||||
data.maxspeed = parse_maxspeed(way:get_value_by_key ( "maxspeed") )
|
||||
data.maxspeed_forward = parse_maxspeed(way:get_value_by_key( "maxspeed:forward"))
|
||||
data.maxspeed_backward = parse_maxspeed(way:get_value_by_key( "maxspeed:backward"))
|
||||
data.barrier = way:get_value_by_key("barrier")
|
||||
data.oneway = way:get_value_by_key("oneway")
|
||||
data.oneway_bicycle = way:get_value_by_key("oneway:bicycle")
|
||||
|
||||
@@ -120,9 +120,6 @@ function setup()
|
||||
|
||||
-- classes to support for exclude flags
|
||||
excludable = Sequence {
|
||||
Set {'toll'},
|
||||
Set {'motorway'},
|
||||
Set {'ferry'}
|
||||
},
|
||||
|
||||
avoid = Set {
|
||||
@@ -269,7 +266,6 @@ function setup()
|
||||
["at:rural"] = 100,
|
||||
["at:trunk"] = 100,
|
||||
["be:motorway"] = 120,
|
||||
["be-vlg:rural"] = 70,
|
||||
["by:urban"] = 60,
|
||||
["by:motorway"] = 110,
|
||||
["ch:rural"] = 80,
|
||||
|
||||
@@ -6,18 +6,6 @@ Measure = {}
|
||||
local inch_to_meters = 0.0254
|
||||
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.
|
||||
--- according to http://wiki.openstreetmap.org/wiki/Key:maxheight
|
||||
@@ -54,13 +42,6 @@ function Measure.parse_value_kilograms(value)
|
||||
end
|
||||
end
|
||||
|
||||
--- Get maxspeed of specified way in kilometers by hours.
|
||||
function Measure.get_max_speed(raw_value)
|
||||
if raw_value then
|
||||
return Measure.parse_value_speed(raw_value)
|
||||
end
|
||||
end
|
||||
|
||||
-- default maxheight value defined in https://wiki.openstreetmap.org/wiki/Key:maxheight#Non-numerical_values
|
||||
local default_maxheight = 4.5
|
||||
-- Available Non numerical values equal to 4.5; below_default and no_indications are not considered
|
||||
|
||||
@@ -432,7 +432,7 @@ end
|
||||
|
||||
-- maxspeed and advisory maxspeed
|
||||
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)
|
||||
forward = WayHandlers.parse_maxspeed(forward,profile)
|
||||
backward = WayHandlers.parse_maxspeed(backward,profile)
|
||||
@@ -450,9 +450,12 @@ function WayHandlers.parse_maxspeed(source,profile)
|
||||
if not source then
|
||||
return 0
|
||||
end
|
||||
|
||||
local n = Measure.get_max_speed(source)
|
||||
if not n then
|
||||
local n = tonumber(source:match("%d*"))
|
||||
if 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
|
||||
source = string.lower(source)
|
||||
n = profile.maxspeed_table[source]
|
||||
|
||||
+2
-6
@@ -6,12 +6,8 @@ var fs = require('fs');
|
||||
var name = process.argv[2];
|
||||
var cmd = process.argv.slice(3).join(' ');
|
||||
var start = Date.now();
|
||||
exec(cmd, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.log(stdout);
|
||||
console.log(stderr);
|
||||
return process.exit(err.code);
|
||||
}
|
||||
exec(cmd, (err) => {
|
||||
if (err) return console.log(err);
|
||||
var stop = +new Date();
|
||||
var time = (stop - start) / 1000.;
|
||||
fs.appendFileSync('/tmp/osrm.timings', `${name}\t${time}`, 'utf-8');
|
||||
|
||||
@@ -102,6 +102,7 @@ int Contractor::Run()
|
||||
QueryGraph query_graph;
|
||||
std::vector<std::vector<bool>> edge_filters;
|
||||
std::vector<std::vector<bool>> cores;
|
||||
|
||||
std::tie(query_graph, edge_filters) = contractExcludableGraph(
|
||||
toContractorGraph(number_of_edge_based_nodes, std::move(edge_based_edge_list)),
|
||||
std::move(node_weights),
|
||||
|
||||
@@ -560,7 +560,7 @@ bool IsNodeIndependent(const util::XORFastHash<> &hash,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::vector<bool> contractGraph(ContractorGraph &graph,
|
||||
std::vector<bool> node_is_uncontracted_,
|
||||
|
||||
@@ -76,7 +76,6 @@ auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
|
||||
const partitioner::MultiLevelPartition &mlp,
|
||||
std::vector<EdgeWeight> &node_weights,
|
||||
std::vector<EdgeDuration> &node_durations,
|
||||
std::vector<EdgeDistance> &node_distances,
|
||||
std::uint32_t &connectivity_checksum)
|
||||
{
|
||||
updater::Updater updater(config.updater_config);
|
||||
@@ -85,8 +84,6 @@ auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
|
||||
EdgeID num_nodes = updater.LoadAndUpdateEdgeExpandedGraph(
|
||||
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 tidied = partitioner::prepareEdgesForUsageInGraph<
|
||||
@@ -127,11 +124,10 @@ int Customizer::Run(const CustomizationConfig &config)
|
||||
partitioner::files::readPartition(config.GetPath(".osrm.partition"), mlp);
|
||||
|
||||
std::vector<EdgeWeight> node_weights;
|
||||
std::vector<EdgeDuration> node_durations; // TODO: remove when durations are optional
|
||||
std::vector<EdgeDistance> node_distances; // TODO: remove when distances are optional
|
||||
std::vector<EdgeDuration> node_durations; // TODO: to be removed later
|
||||
std::uint32_t connectivity_checksum = 0;
|
||||
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());
|
||||
std::for_each(node_weights.begin(), node_weights.end(), [](auto &w) { w &= 0x7fffffff; });
|
||||
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";
|
||||
|
||||
TIMER_START(writing_graph);
|
||||
MultiLevelEdgeBasedGraph shaved_graph{std::move(graph),
|
||||
std::move(node_weights),
|
||||
std::move(node_durations),
|
||||
std::move(node_distances)};
|
||||
MultiLevelEdgeBasedGraph shaved_graph{
|
||||
std::move(graph), std::move(node_weights), std::move(node_durations)};
|
||||
customizer::files::writeGraph(
|
||||
config.GetPath(".osrm.mldgr"), shaved_graph, connectivity_checksum);
|
||||
TIMER_STOP(writing_graph);
|
||||
|
||||
@@ -94,7 +94,7 @@ std::string waypointTypeToString(const guidance::WaypointType 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;
|
||||
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;
|
||||
}
|
||||
|
||||
util::json::Object
|
||||
makeWaypoint(const util::Coordinate &location, const double &distance, std::string name)
|
||||
util::json::Object makeWaypoint(const util::Coordinate location, std::string name)
|
||||
{
|
||||
util::json::Object waypoint;
|
||||
waypoint.values["location"] = detail::coordinateToLonLat(location);
|
||||
waypoint.values["name"] = std::move(name);
|
||||
waypoint.values["distance"] = distance;
|
||||
return waypoint;
|
||||
}
|
||||
|
||||
util::json::Object makeWaypoint(const util::Coordinate &location,
|
||||
const double &distance,
|
||||
std::string name,
|
||||
const Hint &hint)
|
||||
util::json::Object makeWaypoint(const util::Coordinate location, std::string name, const Hint &hint)
|
||||
{
|
||||
auto waypoint = makeWaypoint(location, distance, name);
|
||||
auto waypoint = makeWaypoint(location, name);
|
||||
waypoint.values["hint"] = hint.ToBase64();
|
||||
return waypoint;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "engine/datafacade/mmap_memory_allocator.hpp"
|
||||
|
||||
#include "storage/block.hpp"
|
||||
#include "storage/io.hpp"
|
||||
#include "storage/serialization.hpp"
|
||||
#include "storage/storage.hpp"
|
||||
@@ -8,7 +7,7 @@
|
||||
#include "util/log.hpp"
|
||||
#include "util/mmap_file.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include "boost/assert.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -17,50 +16,46 @@ namespace engine
|
||||
namespace datafacade
|
||||
{
|
||||
|
||||
MMapMemoryAllocator::MMapMemoryAllocator(const storage::StorageConfig &config)
|
||||
MMapMemoryAllocator::MMapMemoryAllocator(const storage::StorageConfig &config,
|
||||
const boost::filesystem::path &memory_file)
|
||||
{
|
||||
storage::Storage storage(config);
|
||||
std::vector<storage::SharedDataIndex::AllocatedRegion> allocated_regions;
|
||||
|
||||
if (!boost::filesystem::exists(memory_file))
|
||||
{
|
||||
std::unique_ptr<storage::BaseDataLayout> fake_layout =
|
||||
std::make_unique<storage::TarDataLayout>();
|
||||
storage::DataLayout initial_layout;
|
||||
storage.PopulateStaticLayout(initial_layout);
|
||||
storage.PopulateUpdatableLayout(initial_layout);
|
||||
|
||||
// Convert the boost::filesystem::path object into a plain string
|
||||
// that's stored as a member of this allocator object
|
||||
rtree_filename = storage.PopulateLayoutWithRTree(*fake_layout);
|
||||
auto data_size = initial_layout.GetSizeOfLayout();
|
||||
|
||||
// Now, we add one more AllocatedRegion, with it's start address as the start
|
||||
// of the rtree_filename string we've saved. In the fake_layout, we've
|
||||
// stated that the data is at offset 0, which is where the string starts
|
||||
// at it's own memory address.
|
||||
// The syntax &(rtree_filename[0]) gets the memory address of the first char.
|
||||
// We can't use the convenient `.data()` or `.c_str()` methods, because
|
||||
// prior to C++17 (which we're not using), those return a `const char *`,
|
||||
// which isn't compatible with the `char *` that AllocatedRegion expects
|
||||
// for it's memory_ptr
|
||||
allocated_regions.push_back({&(rtree_filename[0]), std::move(fake_layout)});
|
||||
storage::io::BufferWriter writer;
|
||||
storage::serialization::write(writer, initial_layout);
|
||||
auto encoded_layout = writer.GetBuffer();
|
||||
|
||||
auto total_size = data_size + encoded_layout.size();
|
||||
|
||||
mapped_memory = util::mmapFile<char>(memory_file, mapped_memory_file, total_size);
|
||||
|
||||
std::copy(encoded_layout.begin(), encoded_layout.end(), mapped_memory.data());
|
||||
|
||||
index = storage::SharedDataIndex(
|
||||
{{mapped_memory.data() + encoded_layout.size(), std::move(initial_layout)}});
|
||||
|
||||
storage.PopulateStaticData(index);
|
||||
storage.PopulateUpdatableData(index);
|
||||
}
|
||||
|
||||
auto files = storage.GetStaticFiles();
|
||||
auto updatable_files = storage.GetUpdatableFiles();
|
||||
files.insert(files.end(), updatable_files.begin(), updatable_files.end());
|
||||
|
||||
for (const auto &file : files)
|
||||
else
|
||||
{
|
||||
if (boost::filesystem::exists(file.second))
|
||||
{
|
||||
std::unique_ptr<storage::BaseDataLayout> layout =
|
||||
std::make_unique<storage::TarDataLayout>();
|
||||
boost::iostreams::mapped_file mapped_memory_file;
|
||||
util::mmapFile<char>(file.second, mapped_memory_file);
|
||||
mapped_memory_files.push_back(std::move(mapped_memory_file));
|
||||
storage::populateLayoutFromFile(file.second, *layout);
|
||||
allocated_regions.push_back({mapped_memory_file.data(), std::move(layout)});
|
||||
}
|
||||
}
|
||||
mapped_memory = util::mmapFile<char>(memory_file, mapped_memory_file);
|
||||
|
||||
index = storage::SharedDataIndex{std::move(allocated_regions)};
|
||||
storage::DataLayout layout;
|
||||
storage::io::BufferReader reader(mapped_memory.data(), mapped_memory.size());
|
||||
storage::serialization::read(reader, layout);
|
||||
auto layout_size = reader.GetPosition();
|
||||
|
||||
index = storage::SharedDataIndex({{mapped_memory.data() + layout_size, std::move(layout)}});
|
||||
}
|
||||
}
|
||||
|
||||
MMapMemoryAllocator::~MMapMemoryAllocator() {}
|
||||
|
||||
@@ -15,20 +15,14 @@ ProcessMemoryAllocator::ProcessMemoryAllocator(const storage::StorageConfig &con
|
||||
storage::Storage storage(config);
|
||||
|
||||
// Calculate the layout/size of the memory block
|
||||
auto static_files = storage.GetStaticFiles();
|
||||
auto updatable_files = storage.GetUpdatableFiles();
|
||||
std::unique_ptr<storage::BaseDataLayout> layout =
|
||||
std::make_unique<storage::ContiguousDataLayout>();
|
||||
storage.PopulateLayoutWithRTree(*layout);
|
||||
storage.PopulateLayout(*layout, static_files);
|
||||
storage.PopulateLayout(*layout, updatable_files);
|
||||
storage::DataLayout layout;
|
||||
storage.PopulateStaticLayout(layout);
|
||||
storage.PopulateUpdatableLayout(layout);
|
||||
|
||||
// Allocate the memory block, then load data from files into it
|
||||
internal_memory = std::make_unique<char[]>(layout->GetSizeOfLayout());
|
||||
internal_memory = std::make_unique<char[]>(layout.GetSizeOfLayout());
|
||||
|
||||
std::vector<storage::SharedDataIndex::AllocatedRegion> regions;
|
||||
regions.push_back({internal_memory.get(), std::move(layout)});
|
||||
index = {std::move(regions)};
|
||||
index = storage::SharedDataIndex({{internal_memory.get(), std::move(layout)}});
|
||||
|
||||
storage.PopulateStaticData(index);
|
||||
storage.PopulateUpdatableData(index);
|
||||
|
||||
@@ -25,9 +25,8 @@ SharedMemoryAllocator::SharedMemoryAllocator(
|
||||
auto mem = storage::makeSharedMemory(shm_key);
|
||||
|
||||
storage::io::BufferReader reader(reinterpret_cast<char *>(mem->Ptr()), mem->Size());
|
||||
std::unique_ptr<storage::BaseDataLayout> layout =
|
||||
std::make_unique<storage::ContiguousDataLayout>();
|
||||
storage::serialization::read(reader, *layout);
|
||||
storage::DataLayout layout;
|
||||
storage::serialization::read(reader, layout);
|
||||
auto layout_size = reader.GetPosition();
|
||||
|
||||
regions.push_back({reinterpret_cast<char *>(mem->Ptr()) + layout_size, std::move(layout)});
|
||||
|
||||
@@ -23,9 +23,7 @@ bool EngineConfig::IsValid() const
|
||||
unlimited_or_more_than(max_results_nearest, 0) &&
|
||||
max_alternatives >= 0;
|
||||
|
||||
return ((use_shared_memory && all_path_are_empty) || (use_mmap && storage_config.IsValid()) ||
|
||||
storage_config.IsValid()) &&
|
||||
limits_valid;
|
||||
return ((use_shared_memory && all_path_are_empty) || storage_config.IsValid()) && limits_valid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,8 +213,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
});
|
||||
}
|
||||
|
||||
auto candidates_lists =
|
||||
GetPhantomNodesInRange(facade, tidied.parameters, search_radiuses, true);
|
||||
auto candidates_lists = GetPhantomNodesInRange(facade, tidied.parameters, search_radiuses);
|
||||
|
||||
filterCandidates(tidied.parameters.coordinates, candidates_lists);
|
||||
if (std::all_of(candidates_lists.begin(),
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "engine/api/table_parameters.hpp"
|
||||
#include "engine/routing_algorithms/many_to_many.hpp"
|
||||
#include "engine/search_engine_data.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/json_container.hpp"
|
||||
#include "util/string_util.hpp"
|
||||
|
||||
@@ -87,7 +86,7 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
bool request_duration = params.annotations & api::TableParameters::AnnotationsType::Duration;
|
||||
|
||||
auto result_tables_pair = algorithms.ManyToManySearch(
|
||||
snapped_phantoms, params.sources, params.destinations, request_distance);
|
||||
snapped_phantoms, params.sources, params.destinations, request_distance, request_duration);
|
||||
|
||||
if ((request_duration && result_tables_pair.first.empty()) ||
|
||||
(request_distance && result_tables_pair.second.empty()))
|
||||
@@ -95,66 +94,8 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
return Error("NoTable", "No table found", result);
|
||||
}
|
||||
|
||||
std::vector<api::TableAPI::TableCellRef> estimated_pairs;
|
||||
|
||||
// Scan table for null results - if any exist, replace with distance estimates
|
||||
if (params.fallback_speed != INVALID_FALLBACK_SPEED || params.scale_factor != 1)
|
||||
{
|
||||
for (std::size_t row = 0; row < num_sources; row++)
|
||||
{
|
||||
for (std::size_t column = 0; column < num_destinations; column++)
|
||||
{
|
||||
const auto &table_index = row * num_destinations + column;
|
||||
BOOST_ASSERT(table_index < result_tables_pair.first.size());
|
||||
if (params.fallback_speed != INVALID_FALLBACK_SPEED && params.fallback_speed > 0 &&
|
||||
result_tables_pair.first[table_index] == MAXIMAL_EDGE_DURATION)
|
||||
{
|
||||
const auto &source =
|
||||
snapped_phantoms[params.sources.empty() ? row : params.sources[row]];
|
||||
const auto &destination =
|
||||
snapped_phantoms[params.destinations.empty() ? column
|
||||
: params.destinations[column]];
|
||||
|
||||
auto distance_estimate =
|
||||
params.fallback_coordinate_type ==
|
||||
api::TableParameters::FallbackCoordinateType::Input
|
||||
? util::coordinate_calculation::fccApproximateDistance(
|
||||
source.input_location, destination.input_location)
|
||||
: util::coordinate_calculation::fccApproximateDistance(
|
||||
source.location, destination.location);
|
||||
|
||||
result_tables_pair.first[table_index] =
|
||||
distance_estimate / (double)params.fallback_speed;
|
||||
if (!result_tables_pair.second.empty())
|
||||
{
|
||||
result_tables_pair.second[table_index] = distance_estimate;
|
||||
}
|
||||
|
||||
estimated_pairs.emplace_back(row, column);
|
||||
}
|
||||
if (params.scale_factor > 0 && params.scale_factor != 1 &&
|
||||
result_tables_pair.first[table_index] != MAXIMAL_EDGE_DURATION &&
|
||||
result_tables_pair.first[table_index] != 0)
|
||||
{
|
||||
EdgeDuration diff =
|
||||
MAXIMAL_EDGE_DURATION / result_tables_pair.first[table_index];
|
||||
|
||||
if (params.scale_factor >= diff)
|
||||
{
|
||||
result_tables_pair.first[table_index] = MAXIMAL_EDGE_DURATION - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
result_tables_pair.first[table_index] = std::lround(
|
||||
result_tables_pair.first[table_index] * params.scale_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
api::TableAPI table_api{facade, params};
|
||||
table_api.MakeResponse(result_tables_pair, snapped_phantoms, estimated_pairs, result);
|
||||
table_api.MakeResponse(result_tables_pair, snapped_phantoms, result);
|
||||
|
||||
return Status::Ok;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,6 @@ struct SpeedLayer : public vtzero::layer_builder
|
||||
vtzero::index_value key_duration;
|
||||
vtzero::index_value key_name;
|
||||
vtzero::index_value key_rate;
|
||||
vtzero::index_value key_is_startpoint;
|
||||
|
||||
SpeedLayer(vtzero::tile_builder &tile)
|
||||
: layer_builder(tile, "speeds"), uint_index(*this), double_index(*this),
|
||||
@@ -303,8 +302,7 @@ struct SpeedLayer : public vtzero::layer_builder
|
||||
key_datasource(add_key_without_dup_check("datasource")),
|
||||
key_weight(add_key_without_dup_check("weight")),
|
||||
key_duration(add_key_without_dup_check("duration")),
|
||||
key_name(add_key_without_dup_check("name")), key_rate(add_key_without_dup_check("rate")),
|
||||
key_is_startpoint(add_key_without_dup_check("is_startpoint"))
|
||||
key_name(add_key_without_dup_check("name")), key_rate(add_key_without_dup_check("rate"))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -351,11 +349,6 @@ class SpeedLayerFeatureBuilder : public vtzero::linestring_feature_builder
|
||||
|
||||
void set_rate(double value) { add_property(m_layer.key_rate, m_layer.double_index(value)); }
|
||||
|
||||
void set_is_startpoint(bool value)
|
||||
{
|
||||
add_property(m_layer.key_is_startpoint, m_layer.bool_index(value));
|
||||
}
|
||||
|
||||
}; // class SpeedLayerFeatureBuilder
|
||||
|
||||
struct TurnsLayer : public vtzero::layer_builder
|
||||
@@ -492,8 +485,6 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
||||
const auto reverse_datasource_idx = reverse_datasource_range(
|
||||
reverse_datasource_range.size() - edge.fwd_segment_position - 1);
|
||||
|
||||
const auto is_startpoint = edge.is_startpoint;
|
||||
|
||||
const auto component_id = facade.GetComponentID(edge.forward_segment_id.id);
|
||||
const auto name_id = facade.GetNameIndex(edge.forward_segment_id.id);
|
||||
auto name = facade.GetNameForID(name_id);
|
||||
@@ -525,7 +516,6 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
||||
fbuilder.set_duration(forward_duration / 10.0);
|
||||
fbuilder.set_name(name);
|
||||
fbuilder.set_rate(forward_rate / 10.0);
|
||||
fbuilder.set_is_startpoint(is_startpoint);
|
||||
|
||||
fbuilder.commit();
|
||||
}
|
||||
@@ -559,7 +549,6 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
||||
fbuilder.set_duration(reverse_duration / 10.0);
|
||||
fbuilder.set_name(name);
|
||||
fbuilder.set_rate(reverse_rate / 10.0);
|
||||
fbuilder.set_is_startpoint(is_startpoint);
|
||||
|
||||
fbuilder.commit();
|
||||
}
|
||||
|
||||
@@ -217,7 +217,10 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
|
||||
// compute the duration table of all phantom nodes
|
||||
auto result_duration_table = util::DistTableWrapper<EdgeWeight>(
|
||||
algorithms.ManyToManySearch(snapped_phantoms, {}, {}, /*requestDistance*/ false).first,
|
||||
algorithms
|
||||
.ManyToManySearch(
|
||||
snapped_phantoms, {}, {}, /*requestDistance*/ false, /*requestDuration*/ true)
|
||||
.first,
|
||||
number_of_locations);
|
||||
|
||||
if (result_duration_table.size() == 0)
|
||||
|
||||
@@ -558,7 +558,7 @@ bool viaNodeCandidatePassesTTest(SearchEngineData<Algorithm> &engine_working_dat
|
||||
}
|
||||
return (upper_bound <= t_test_path_weight);
|
||||
}
|
||||
} // anon. namespace
|
||||
} // namespace
|
||||
|
||||
InternalManyRoutesResult alternativePathSearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const DataFacade<Algorithm> &facade,
|
||||
@@ -853,4 +853,4 @@ InternalManyRoutesResult alternativePathSearch(SearchEngineData<Algorithm> &engi
|
||||
|
||||
} // namespace routing_algorithms
|
||||
} // namespace engine
|
||||
} // namespace osrm}
|
||||
} // namespace osrm
|
||||
|
||||
@@ -120,13 +120,8 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
const auto target_distance = current_bucket.distance;
|
||||
|
||||
auto ¤t_weight = weights_table[row_index * number_of_targets + column_index];
|
||||
|
||||
EdgeDistance nulldistance = 0;
|
||||
|
||||
auto ¤t_duration = durations_table[row_index * number_of_targets + column_index];
|
||||
auto ¤t_distance =
|
||||
distances_table.empty() ? nulldistance
|
||||
: distances_table[row_index * number_of_targets + column_index];
|
||||
auto ¤t_distance = distances_table[row_index * number_of_targets + column_index];
|
||||
|
||||
// Check if new weight is better
|
||||
auto new_weight = source_weight + target_weight;
|
||||
@@ -178,6 +173,160 @@ void backwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
|
||||
} // namespace ch
|
||||
|
||||
void retrievePackedPathFromSearchSpace(const NodeID middle_node_id,
|
||||
const unsigned column_index,
|
||||
const std::vector<NodeBucket> &search_space_with_buckets,
|
||||
std::vector<NodeID> &packed_leg)
|
||||
{
|
||||
auto bucket_list = std::equal_range(search_space_with_buckets.begin(),
|
||||
search_space_with_buckets.end(),
|
||||
middle_node_id,
|
||||
NodeBucket::ColumnCompare(column_index));
|
||||
|
||||
NodeID current_node_id = middle_node_id;
|
||||
|
||||
BOOST_ASSERT_MSG(std::distance(bucket_list.first, bucket_list.second) == 1,
|
||||
"The pointers are not pointing to the same element.");
|
||||
|
||||
while (bucket_list.first->parent_node != current_node_id &&
|
||||
bucket_list.first != search_space_with_buckets.end())
|
||||
{
|
||||
current_node_id = bucket_list.first->parent_node;
|
||||
|
||||
packed_leg.emplace_back(current_node_id);
|
||||
|
||||
bucket_list = std::equal_range(search_space_with_buckets.begin(),
|
||||
search_space_with_buckets.end(),
|
||||
current_node_id,
|
||||
NodeBucket::ColumnCompare(column_index));
|
||||
}
|
||||
}
|
||||
|
||||
void calculateDistances(typename SearchEngineData<ch::Algorithm>::ManyToManyQueryHeap &query_heap,
|
||||
const DataFacade<ch::Algorithm> &facade,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &target_indices,
|
||||
const std::size_t row_index,
|
||||
const std::size_t source_index,
|
||||
const PhantomNode &source_phantom,
|
||||
const std::size_t number_of_targets,
|
||||
const std::vector<NodeBucket> &search_space_with_buckets,
|
||||
std::vector<EdgeDistance> &distances_table,
|
||||
const std::vector<NodeID> &middle_nodes_table)
|
||||
{
|
||||
std::vector<NodeID> packed_leg;
|
||||
|
||||
for (auto column_index : util::irange<std::size_t>(0, number_of_targets))
|
||||
{
|
||||
const auto target_index = target_indices[column_index];
|
||||
const auto &target_phantom = phantom_nodes[target_index];
|
||||
|
||||
if (source_index == target_index)
|
||||
{
|
||||
distances_table[row_index * number_of_targets + column_index] = 0.0;
|
||||
continue;
|
||||
}
|
||||
|
||||
NodeID middle_node_id = middle_nodes_table[row_index * number_of_targets + column_index];
|
||||
|
||||
if (middle_node_id == SPECIAL_NODEID) // takes care of one-ways
|
||||
{
|
||||
distances_table[row_index * number_of_targets + column_index] = INVALID_EDGE_DISTANCE;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Step 1: Find path from source to middle node
|
||||
ch::retrievePackedPathFromSingleManyToManyHeap(query_heap, middle_node_id, packed_leg);
|
||||
std::reverse(packed_leg.begin(), packed_leg.end());
|
||||
|
||||
packed_leg.push_back(middle_node_id);
|
||||
|
||||
// Step 2: Find path from middle to target node
|
||||
retrievePackedPathFromSearchSpace(
|
||||
middle_node_id, column_index, search_space_with_buckets, packed_leg);
|
||||
|
||||
if (packed_leg.size() == 1 && (needsLoopForward(source_phantom, target_phantom) ||
|
||||
needsLoopBackwards(source_phantom, target_phantom)))
|
||||
{
|
||||
auto weight = ch::getLoopWeight<false>(facade, packed_leg.front());
|
||||
if (std::get<0>(weight) != INVALID_EDGE_WEIGHT)
|
||||
packed_leg.push_back(packed_leg.front());
|
||||
}
|
||||
if (!packed_leg.empty())
|
||||
{
|
||||
auto annotation =
|
||||
ch::calculateEBGNodeAnnotations(facade, packed_leg.begin(), packed_leg.end());
|
||||
|
||||
distances_table[row_index * number_of_targets + column_index] = annotation;
|
||||
|
||||
// check the direction of travel to figure out how to calculate the offset to/from
|
||||
// the source/target
|
||||
if (source_phantom.forward_segment_id.id == packed_leg.front())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// -->s <-- subtract offset to start at source
|
||||
// ......... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
EdgeDistance offset = source_phantom.GetForwardDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] -= offset;
|
||||
}
|
||||
else if (source_phantom.reverse_segment_id.id == packed_leg.front())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// s<------- <-- subtract offset to start at source
|
||||
// ... <-- want this distance
|
||||
// entry 0---1---2---3 <-- 3 is exit node
|
||||
EdgeDistance offset = source_phantom.GetReverseDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] -= offset;
|
||||
}
|
||||
if (target_phantom.forward_segment_id.id == packed_leg.back())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// ++>t <-- add offset to get to target
|
||||
// ................ <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
EdgeDistance offset = target_phantom.GetForwardDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] += offset;
|
||||
}
|
||||
else if (target_phantom.reverse_segment_id.id == packed_leg.back())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// <++t <-- add offset to get from target
|
||||
// ................ <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
EdgeDistance offset = target_phantom.GetReverseDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] += offset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is no shortcut to unpack. source and target are on the same EBG Node.
|
||||
// if the offset of the target is greater than the offset of the source, subtract it
|
||||
if (target_phantom.GetForwardDistance() > source_phantom.GetForwardDistance())
|
||||
{
|
||||
// --------->t <-- offsets
|
||||
// ->s <-- subtract source offset from target offset
|
||||
// ......... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
EdgeDistance offset =
|
||||
target_phantom.GetForwardDistance() - source_phantom.GetForwardDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] = offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
// s<--- <-- offsets
|
||||
// t<--------- <-- subtract source offset from target offset
|
||||
// ...... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
EdgeDistance offset =
|
||||
target_phantom.GetReverseDistance() - source_phantom.GetReverseDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] = offset;
|
||||
}
|
||||
}
|
||||
packed_leg.clear();
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>>
|
||||
manyToManySearch(SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
@@ -185,16 +334,18 @@ manyToManySearch(SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &source_indices,
|
||||
const std::vector<std::size_t> &target_indices,
|
||||
const bool calculate_distance)
|
||||
const bool calculate_distance,
|
||||
const bool calculate_duration)
|
||||
{
|
||||
(void)calculate_duration; // TODO: stub to use when computing durations become optional
|
||||
|
||||
const auto number_of_sources = source_indices.size();
|
||||
const auto number_of_targets = target_indices.size();
|
||||
const auto number_of_entries = number_of_sources * number_of_targets;
|
||||
|
||||
std::vector<EdgeWeight> weights_table(number_of_entries, INVALID_EDGE_WEIGHT);
|
||||
std::vector<EdgeDuration> durations_table(number_of_entries, MAXIMAL_EDGE_DURATION);
|
||||
std::vector<EdgeDistance> distances_table(calculate_distance ? number_of_entries : 0,
|
||||
MAXIMAL_EDGE_DISTANCE);
|
||||
std::vector<EdgeDistance> distances_table(number_of_entries, MAXIMAL_EDGE_DISTANCE);
|
||||
std::vector<NodeID> middle_nodes_table(number_of_entries, SPECIAL_NODEID);
|
||||
|
||||
std::vector<NodeBucket> search_space_with_buckets;
|
||||
@@ -247,6 +398,26 @@ manyToManySearch(SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
middle_nodes_table,
|
||||
source_phantom);
|
||||
}
|
||||
|
||||
if (calculate_distance)
|
||||
{
|
||||
distances_table.resize(number_of_entries, INVALID_EDGE_DISTANCE);
|
||||
// TODO: this is a hack to work around stuff
|
||||
if (number_of_entries == 0)
|
||||
{
|
||||
calculateDistances(query_heap,
|
||||
facade,
|
||||
phantom_nodes,
|
||||
target_indices,
|
||||
row_index,
|
||||
source_index,
|
||||
source_phantom,
|
||||
number_of_targets,
|
||||
search_space_with_buckets,
|
||||
distances_table,
|
||||
middle_nodes_table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair(durations_table, distances_table);
|
||||
|
||||
@@ -41,7 +41,7 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
const NodeID node,
|
||||
const EdgeWeight weight,
|
||||
const EdgeDuration duration,
|
||||
const EdgeDistance distance,
|
||||
const EdgeDistance /* distance TODO use this */,
|
||||
typename SearchEngineData<mld::Algorithm>::ManyToManyQueryHeap &query_heap,
|
||||
Args... args)
|
||||
{
|
||||
@@ -66,77 +66,65 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
{ // Shortcuts in forward direction
|
||||
auto destination = cell.GetDestinationNodes().begin();
|
||||
auto shortcut_durations = cell.GetOutDuration(node);
|
||||
auto shortcut_distances = cell.GetOutDistance(node);
|
||||
for (auto shortcut_weight : cell.GetOutWeight(node))
|
||||
{
|
||||
BOOST_ASSERT(destination != cell.GetDestinationNodes().end());
|
||||
BOOST_ASSERT(!shortcut_durations.empty());
|
||||
BOOST_ASSERT(!shortcut_distances.empty());
|
||||
const NodeID to = *destination;
|
||||
|
||||
if (shortcut_weight != INVALID_EDGE_WEIGHT && node != to)
|
||||
{
|
||||
const auto to_weight = weight + shortcut_weight;
|
||||
const auto to_duration = duration + shortcut_durations.front();
|
||||
const auto to_distance = distance + shortcut_distances.front();
|
||||
if (!query_heap.WasInserted(to))
|
||||
{
|
||||
query_heap.Insert(to, to_weight, {node, true, to_duration, to_distance});
|
||||
query_heap.Insert(to, to_weight, {node, true, to_duration, 0});
|
||||
}
|
||||
else if (std::tie(to_weight, to_duration, to_distance, node) <
|
||||
else if (std::tie(to_weight, to_duration, node) <
|
||||
std::tie(query_heap.GetKey(to),
|
||||
query_heap.GetData(to).duration,
|
||||
query_heap.GetData(to).distance,
|
||||
query_heap.GetData(to).parent))
|
||||
{
|
||||
query_heap.GetData(to) = {node, true, to_duration, to_distance};
|
||||
query_heap.GetData(to) = {node, true, to_duration, 0};
|
||||
query_heap.DecreaseKey(to, to_weight);
|
||||
}
|
||||
}
|
||||
++destination;
|
||||
shortcut_durations.advance_begin(1);
|
||||
shortcut_distances.advance_begin(1);
|
||||
}
|
||||
BOOST_ASSERT(shortcut_durations.empty());
|
||||
BOOST_ASSERT(shortcut_distances.empty());
|
||||
}
|
||||
else
|
||||
{ // Shortcuts in backward direction
|
||||
auto source = cell.GetSourceNodes().begin();
|
||||
auto shortcut_durations = cell.GetInDuration(node);
|
||||
auto shortcut_distances = cell.GetInDistance(node);
|
||||
for (auto shortcut_weight : cell.GetInWeight(node))
|
||||
{
|
||||
BOOST_ASSERT(source != cell.GetSourceNodes().end());
|
||||
BOOST_ASSERT(!shortcut_durations.empty());
|
||||
BOOST_ASSERT(!shortcut_distances.empty());
|
||||
const NodeID to = *source;
|
||||
|
||||
if (shortcut_weight != INVALID_EDGE_WEIGHT && node != to)
|
||||
{
|
||||
const auto to_weight = weight + shortcut_weight;
|
||||
const auto to_duration = duration + shortcut_durations.front();
|
||||
const auto to_distance = distance + shortcut_distances.front();
|
||||
if (!query_heap.WasInserted(to))
|
||||
{
|
||||
query_heap.Insert(to, to_weight, {node, true, to_duration, to_distance});
|
||||
query_heap.Insert(to, to_weight, {node, true, to_duration, 0});
|
||||
}
|
||||
else if (std::tie(to_weight, to_duration, to_distance, node) <
|
||||
else if (std::tie(to_weight, to_duration, node) <
|
||||
std::tie(query_heap.GetKey(to),
|
||||
query_heap.GetData(to).duration,
|
||||
query_heap.GetData(to).distance,
|
||||
query_heap.GetData(to).parent))
|
||||
{
|
||||
query_heap.GetData(to) = {node, true, to_duration, to_distance};
|
||||
query_heap.GetData(to) = {node, true, to_duration, 0};
|
||||
query_heap.DecreaseKey(to, to_weight);
|
||||
}
|
||||
}
|
||||
++source;
|
||||
shortcut_durations.advance_begin(1);
|
||||
shortcut_distances.advance_begin(1);
|
||||
}
|
||||
BOOST_ASSERT(shortcut_durations.empty());
|
||||
BOOST_ASSERT(shortcut_distances.empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,28 +144,25 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
const auto node_id = DIRECTION == FORWARD_DIRECTION ? node : facade.GetTarget(edge);
|
||||
const auto node_weight = facade.GetNodeWeight(node_id);
|
||||
const auto node_duration = facade.GetNodeDuration(node_id);
|
||||
const auto node_distance = facade.GetNodeDistance(node_id);
|
||||
const auto turn_weight = node_weight + facade.GetWeightPenaltyForEdgeID(turn_id);
|
||||
const auto turn_duration = node_duration + facade.GetDurationPenaltyForEdgeID(turn_id);
|
||||
|
||||
BOOST_ASSERT_MSG(node_weight + turn_weight > 0, "edge weight is invalid");
|
||||
const auto to_weight = weight + turn_weight;
|
||||
const auto to_duration = duration + turn_duration;
|
||||
const auto to_distance = distance + node_distance;
|
||||
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!query_heap.WasInserted(to))
|
||||
{
|
||||
query_heap.Insert(to, to_weight, {node, false, to_duration, to_distance});
|
||||
query_heap.Insert(to, to_weight, {node, false, to_duration, 0});
|
||||
}
|
||||
// Found a shorter Path -> Update weight and set new parent
|
||||
else if (std::tie(to_weight, to_duration, to_distance, node) <
|
||||
else if (std::tie(to_weight, to_duration, node) <
|
||||
std::tie(query_heap.GetKey(to),
|
||||
query_heap.GetData(to).duration,
|
||||
query_heap.GetData(to).distance,
|
||||
query_heap.GetData(to).parent))
|
||||
{
|
||||
query_heap.GetData(to) = {node, false, to_duration, to_distance};
|
||||
query_heap.GetData(to) = {node, false, to_duration, 0};
|
||||
query_heap.DecreaseKey(to, to_weight);
|
||||
}
|
||||
}
|
||||
@@ -194,12 +179,11 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
std::size_t phantom_index,
|
||||
const std::vector<std::size_t> &phantom_indices,
|
||||
const bool calculate_distance)
|
||||
const bool /* calculate_distance */)
|
||||
{
|
||||
std::vector<EdgeWeight> weights(phantom_indices.size(), INVALID_EDGE_WEIGHT);
|
||||
std::vector<EdgeDuration> durations(phantom_indices.size(), MAXIMAL_EDGE_DURATION);
|
||||
std::vector<EdgeDistance> distances_table(calculate_distance ? phantom_indices.size() : 0,
|
||||
MAXIMAL_EDGE_DISTANCE);
|
||||
std::vector<EdgeDistance> distances_table(phantom_indices.size(), MAXIMAL_EDGE_DISTANCE);
|
||||
std::vector<NodeID> middle_nodes_table(phantom_indices.size(), SPECIAL_NODEID);
|
||||
|
||||
// Collect destination (source) nodes into a map
|
||||
@@ -261,7 +245,7 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
std::size_t index;
|
||||
EdgeWeight target_weight;
|
||||
EdgeDuration target_duration;
|
||||
EdgeDistance target_distance;
|
||||
EdgeDuration target_distance;
|
||||
std::tie(index, target_weight, target_duration, target_distance) = it->second;
|
||||
|
||||
const auto path_weight = weight + target_weight;
|
||||
@@ -270,16 +254,12 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const auto path_duration = duration + target_duration;
|
||||
const auto path_distance = distance + target_distance;
|
||||
|
||||
EdgeDistance nulldistance = 0;
|
||||
auto ¤t_distance =
|
||||
distances_table.empty() ? nulldistance : distances_table[index];
|
||||
|
||||
if (std::tie(path_weight, path_duration, path_distance) <
|
||||
std::tie(weights[index], durations[index], current_distance))
|
||||
if (std::tie(path_weight, path_duration) <
|
||||
std::tie(weights[index], durations[index]))
|
||||
{
|
||||
weights[index] = path_weight;
|
||||
durations[index] = path_duration;
|
||||
current_distance = path_distance;
|
||||
distances_table[index] = path_distance;
|
||||
middle_nodes_table[index] = node;
|
||||
}
|
||||
|
||||
@@ -297,7 +277,6 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
EdgeWeight initial_weight,
|
||||
EdgeDuration initial_duration,
|
||||
EdgeDistance initial_distance) {
|
||||
|
||||
// Update single node paths
|
||||
update_values(node, initial_weight, initial_duration, initial_distance);
|
||||
|
||||
@@ -324,7 +303,7 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
facade.GetWeightPenaltyForEdgeID(turn_id);
|
||||
const auto edge_duration = initial_duration + facade.GetNodeDuration(node_id) +
|
||||
facade.GetDurationPenaltyForEdgeID(turn_id);
|
||||
const auto edge_distance = initial_distance + facade.GetNodeDistance(node_id);
|
||||
const auto edge_distance = initial_distance;
|
||||
|
||||
query_heap.Insert(to, edge_weight, {node, edge_duration, edge_distance});
|
||||
}
|
||||
@@ -395,6 +374,128 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
phantom_indices);
|
||||
}
|
||||
|
||||
// TODO: re-enable this if we need to fallback
|
||||
// if (calculate_distance)
|
||||
if (false)
|
||||
{
|
||||
// Initialize unpacking heaps
|
||||
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||
facade.GetNumberOfNodes(), facade.GetMaxBorderNodeID() + 1);
|
||||
|
||||
distances_table.resize(phantom_indices.size(), INVALID_EDGE_DISTANCE);
|
||||
|
||||
for (unsigned location = 0; location < phantom_indices.size(); ++location)
|
||||
{
|
||||
// Get the "middle" node that is the last node of a path
|
||||
const NodeID middle_node_id = middle_nodes_table[location];
|
||||
if (middle_node_id == SPECIAL_NODEID) // takes care of one-ways
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Retrieve the packed path from the heap
|
||||
PackedPath packed_path = mld::retrievePackedPathFromSingleManyToManyHeap<DIRECTION>(
|
||||
query_heap, middle_node_id);
|
||||
|
||||
// ... and reverse it to have packed edges in the correct order,
|
||||
if (DIRECTION == FORWARD_DIRECTION)
|
||||
{
|
||||
std::reverse(packed_path.begin(), packed_path.end());
|
||||
}
|
||||
|
||||
// ... unpack path
|
||||
auto &forward_heap = *engine_working_data.forward_heap_1;
|
||||
auto &reverse_heap = *engine_working_data.reverse_heap_1;
|
||||
EdgeWeight weight = INVALID_EDGE_WEIGHT;
|
||||
std::vector<NodeID> unpacked_nodes;
|
||||
std::vector<EdgeID> unpacked_edges;
|
||||
|
||||
std::tie(weight, unpacked_nodes, unpacked_edges) =
|
||||
unpackPathAndCalculateDistance(engine_working_data,
|
||||
facade,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
INVALID_EDGE_WEIGHT,
|
||||
packed_path,
|
||||
middle_node_id,
|
||||
phantom_nodes,
|
||||
phantom_index,
|
||||
phantom_indices);
|
||||
|
||||
// Accumulate the path length without the last node
|
||||
auto annotation = 0.0;
|
||||
|
||||
BOOST_ASSERT(!unpacked_nodes.empty());
|
||||
for (auto node = unpacked_nodes.begin(), last_node = std::prev(unpacked_nodes.end());
|
||||
node != last_node;
|
||||
++node)
|
||||
{
|
||||
annotation += computeEdgeDistance(facade, *node);
|
||||
}
|
||||
|
||||
// ... and add negative source and positive target offsets
|
||||
// ⚠ for REVERSE_DIRECTION original source and target phantom nodes are swapped
|
||||
// Get source and target phantom nodes
|
||||
// * 1-to-N: source is a single index, target is the corresponding from the indices list
|
||||
// * N-to-1: source is the corresponding from the indices list, target is a single index
|
||||
auto source_phantom_index = phantom_index;
|
||||
auto target_phantom_index = phantom_indices[location];
|
||||
if (DIRECTION == REVERSE_DIRECTION)
|
||||
{
|
||||
std::swap(source_phantom_index, target_phantom_index);
|
||||
}
|
||||
const auto &source_phantom = phantom_nodes[source_phantom_index];
|
||||
const auto &target_phantom = phantom_nodes[target_phantom_index];
|
||||
const NodeID source_node = unpacked_nodes.front();
|
||||
const NodeID target_node = unpacked_nodes.back();
|
||||
|
||||
EdgeDistance source_offset = 0., target_offset = 0.;
|
||||
if (source_phantom.IsValidForwardSource() &&
|
||||
source_phantom.forward_segment_id.id == source_node)
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0
|
||||
// to 3
|
||||
// -->s <-- subtract offset to start at source
|
||||
// ......... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
source_offset = source_phantom.GetForwardDistance();
|
||||
}
|
||||
else if (source_phantom.IsValidReverseSource() &&
|
||||
source_phantom.reverse_segment_id.id == source_node)
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// s<------- <-- subtract offset to start at source
|
||||
// ... <-- want this distance
|
||||
// entry 0---1---2---3 <-- 3 is exit node
|
||||
source_offset = source_phantom.GetReverseDistance();
|
||||
}
|
||||
if (target_phantom.IsValidForwardTarget() &&
|
||||
target_phantom.forward_segment_id.id == target_node)
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0
|
||||
// to 3
|
||||
// ++>t <-- add offset to get to target
|
||||
// ................ <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
target_offset = target_phantom.GetForwardDistance();
|
||||
}
|
||||
else if (target_phantom.IsValidReverseTarget() &&
|
||||
target_phantom.reverse_segment_id.id == target_node)
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0
|
||||
// to 3
|
||||
// <++t <-- add offset to get from target
|
||||
// ................ <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
target_offset = target_phantom.GetReverseDistance();
|
||||
}
|
||||
|
||||
distances_table[location] = -source_offset + annotation + target_offset;
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair(durations, distances_table);
|
||||
}
|
||||
|
||||
@@ -410,7 +511,6 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
const std::vector<NodeBucket> &search_space_with_buckets,
|
||||
std::vector<EdgeWeight> &weights_table,
|
||||
std::vector<EdgeDuration> &durations_table,
|
||||
std::vector<EdgeDistance> &distances_table,
|
||||
std::vector<NodeID> &middle_nodes_table,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
@@ -430,7 +530,6 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
const auto column_idx = current_bucket.column_index;
|
||||
const auto target_weight = current_bucket.weight;
|
||||
const auto target_duration = current_bucket.duration;
|
||||
const auto target_distance = current_bucket.distance;
|
||||
|
||||
// Get the value location in the results tables:
|
||||
// * row-major direct (row_idx, column_idx) index for forward direction
|
||||
@@ -441,21 +540,15 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
auto ¤t_weight = weights_table[location];
|
||||
auto ¤t_duration = durations_table[location];
|
||||
|
||||
EdgeDistance nulldistance = 0;
|
||||
auto ¤t_distance = distances_table.empty() ? nulldistance : distances_table[location];
|
||||
|
||||
// Check if new weight is better
|
||||
auto new_weight = source_weight + target_weight;
|
||||
auto new_duration = source_duration + target_duration;
|
||||
auto new_distance = source_distance + target_distance;
|
||||
|
||||
if (new_weight >= 0 &&
|
||||
std::tie(new_weight, new_duration, new_distance) <
|
||||
std::tie(current_weight, current_duration, current_distance))
|
||||
std::tie(new_weight, new_duration) < std::tie(current_weight, current_duration))
|
||||
{
|
||||
current_weight = new_weight;
|
||||
current_duration = new_duration;
|
||||
current_distance = new_distance;
|
||||
middle_nodes_table[location] = node;
|
||||
}
|
||||
}
|
||||
@@ -480,7 +573,7 @@ void backwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
|
||||
// Store settled nodes in search space bucket
|
||||
search_space_with_buckets.emplace_back(
|
||||
node, parent, from_clique_arc, column_idx, target_weight, target_duration, target_distance);
|
||||
node, parent, from_clique_arc, column_idx, target_weight, target_duration);
|
||||
|
||||
const auto &partition = facade.GetMultiLevelPartition();
|
||||
const auto maximal_level = partition.GetNumberOfLevels() - 1;
|
||||
@@ -531,6 +624,182 @@ void retrievePackedPathFromSearchSpace(NodeID middle_node_id,
|
||||
}
|
||||
}
|
||||
|
||||
template <bool DIRECTION>
|
||||
void calculateDistances(typename SearchEngineData<mld::Algorithm>::ManyToManyQueryHeap &query_heap,
|
||||
const DataFacade<mld::Algorithm> &facade,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &target_indices,
|
||||
const unsigned row_idx,
|
||||
const std::size_t source_index,
|
||||
const unsigned number_of_sources,
|
||||
const unsigned number_of_targets,
|
||||
const std::vector<NodeBucket> &search_space_with_buckets,
|
||||
std::vector<EdgeDistance> &distances_table,
|
||||
const std::vector<NodeID> &middle_nodes_table,
|
||||
SearchEngineData<mld::Algorithm> &engine_working_data)
|
||||
{
|
||||
engine_working_data.InitializeOrClearFirstThreadLocalStorage(facade.GetNumberOfNodes(),
|
||||
facade.GetMaxBorderNodeID() + 1);
|
||||
|
||||
for (unsigned column_idx = 0; column_idx < number_of_targets; ++column_idx)
|
||||
{
|
||||
// Step 1: Get source and target phantom nodes that were used in the bucketed search
|
||||
auto source_phantom_index = source_index;
|
||||
auto target_phantom_index = target_indices[column_idx];
|
||||
const auto &source_phantom = phantom_nodes[source_phantom_index];
|
||||
const auto &target_phantom = phantom_nodes[target_phantom_index];
|
||||
|
||||
const auto location = DIRECTION == FORWARD_DIRECTION
|
||||
? row_idx * number_of_targets + column_idx
|
||||
: row_idx + column_idx * number_of_sources;
|
||||
|
||||
if (source_phantom_index == target_phantom_index)
|
||||
{
|
||||
distances_table[location] = 0.0;
|
||||
continue;
|
||||
}
|
||||
|
||||
NodeID middle_node_id = middle_nodes_table[location];
|
||||
|
||||
if (middle_node_id == SPECIAL_NODEID) // takes care of one-ways
|
||||
{
|
||||
distances_table[location] = INVALID_EDGE_DISTANCE;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Step 2: Find path from source to middle node
|
||||
PackedPath packed_path =
|
||||
mld::retrievePackedPathFromSingleManyToManyHeap<DIRECTION>(query_heap, middle_node_id);
|
||||
|
||||
if (DIRECTION == FORWARD_DIRECTION)
|
||||
{
|
||||
std::reverse(packed_path.begin(), packed_path.end());
|
||||
}
|
||||
|
||||
auto &forward_heap = *engine_working_data.forward_heap_1;
|
||||
auto &reverse_heap = *engine_working_data.reverse_heap_1;
|
||||
EdgeWeight weight = INVALID_EDGE_WEIGHT;
|
||||
std::vector<NodeID> unpacked_nodes_from_source;
|
||||
std::vector<EdgeID> unpacked_edges;
|
||||
std::tie(weight, unpacked_nodes_from_source, unpacked_edges) =
|
||||
unpackPathAndCalculateDistance(engine_working_data,
|
||||
facade,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
INVALID_EDGE_WEIGHT,
|
||||
packed_path,
|
||||
middle_node_id,
|
||||
source_phantom);
|
||||
|
||||
// Step 3: Find path from middle to target node
|
||||
packed_path.clear();
|
||||
retrievePackedPathFromSearchSpace<DIRECTION>(
|
||||
middle_node_id, column_idx, search_space_with_buckets, packed_path);
|
||||
|
||||
if (DIRECTION == REVERSE_DIRECTION)
|
||||
{
|
||||
std::reverse(packed_path.begin(), packed_path.end());
|
||||
}
|
||||
|
||||
std::vector<NodeID> unpacked_nodes_to_target;
|
||||
std::tie(weight, unpacked_nodes_to_target, unpacked_edges) =
|
||||
unpackPathAndCalculateDistance(engine_working_data,
|
||||
facade,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
INVALID_EDGE_WEIGHT,
|
||||
packed_path,
|
||||
middle_node_id,
|
||||
target_phantom);
|
||||
|
||||
if (DIRECTION == REVERSE_DIRECTION)
|
||||
{
|
||||
std::swap(unpacked_nodes_to_target, unpacked_nodes_from_source);
|
||||
}
|
||||
|
||||
// Step 4: Compute annotation value along the path nodes without the target node
|
||||
auto annotation = 0.0;
|
||||
|
||||
for (auto node = unpacked_nodes_from_source.begin(),
|
||||
last_node = std::prev(unpacked_nodes_from_source.end());
|
||||
node != last_node;
|
||||
++node)
|
||||
{
|
||||
annotation += computeEdgeDistance(facade, *node);
|
||||
}
|
||||
|
||||
for (auto node = unpacked_nodes_to_target.begin(),
|
||||
last_node = std::prev(unpacked_nodes_to_target.end());
|
||||
node != last_node;
|
||||
++node)
|
||||
{
|
||||
annotation += computeEdgeDistance(facade, *node);
|
||||
}
|
||||
|
||||
// Step 5: Get phantom node offsets and compute the annotation value
|
||||
EdgeDistance source_offset = 0., target_offset = 0.;
|
||||
{
|
||||
// ⚠ for REVERSE_DIRECTION original source and target phantom nodes are swapped
|
||||
if (DIRECTION == REVERSE_DIRECTION)
|
||||
{
|
||||
std::swap(source_phantom_index, target_phantom_index);
|
||||
}
|
||||
const auto &source_phantom = phantom_nodes[source_phantom_index];
|
||||
const auto &target_phantom = phantom_nodes[target_phantom_index];
|
||||
|
||||
NodeID source_node = unpacked_nodes_from_source.front();
|
||||
NodeID target_node = unpacked_nodes_to_target.back();
|
||||
|
||||
if (source_phantom.IsValidForwardSource() &&
|
||||
source_phantom.forward_segment_id.id == source_node)
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0
|
||||
// to 3
|
||||
// -->s <-- subtract offset to start at source
|
||||
// ......... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
source_offset = source_phantom.GetForwardDistance();
|
||||
}
|
||||
else if (source_phantom.IsValidReverseSource() &&
|
||||
source_phantom.reverse_segment_id.id == source_node)
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// s<------- <-- subtract offset to start at source
|
||||
// ... <-- want this distance
|
||||
// entry 0---1---2---3 <-- 3 is exit node
|
||||
source_offset = source_phantom.GetReverseDistance();
|
||||
}
|
||||
|
||||
if (target_phantom.IsValidForwardTarget() &&
|
||||
target_phantom.forward_segment_id.id == target_node)
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0
|
||||
// to 3
|
||||
// ++>t <-- add offset to get to target
|
||||
// ................ <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
target_offset = target_phantom.GetForwardDistance();
|
||||
}
|
||||
else if (target_phantom.IsValidReverseTarget() &&
|
||||
target_phantom.reverse_segment_id.id == target_node)
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0
|
||||
// to 3
|
||||
// <++t <-- add offset to get from target
|
||||
// ................ <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
target_offset = target_phantom.GetReverseDistance();
|
||||
}
|
||||
}
|
||||
|
||||
distances_table[location] = -source_offset + annotation + target_offset;
|
||||
}
|
||||
}
|
||||
|
||||
template <bool DIRECTION>
|
||||
std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>>
|
||||
manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
@@ -546,8 +815,7 @@ manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
|
||||
std::vector<EdgeWeight> weights_table(number_of_entries, INVALID_EDGE_WEIGHT);
|
||||
std::vector<EdgeDuration> durations_table(number_of_entries, MAXIMAL_EDGE_DURATION);
|
||||
std::vector<EdgeDistance> distances_table(calculate_distance ? number_of_entries : 0,
|
||||
INVALID_EDGE_DISTANCE);
|
||||
std::vector<EdgeDistance> distances_table;
|
||||
std::vector<NodeID> middle_nodes_table(number_of_entries, SPECIAL_NODEID);
|
||||
|
||||
std::vector<NodeBucket> search_space_with_buckets;
|
||||
@@ -606,10 +874,26 @@ manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
search_space_with_buckets,
|
||||
weights_table,
|
||||
durations_table,
|
||||
distances_table,
|
||||
middle_nodes_table,
|
||||
source_phantom);
|
||||
}
|
||||
|
||||
if (calculate_distance)
|
||||
{
|
||||
distances_table.resize(number_of_entries, INVALID_EDGE_DISTANCE);
|
||||
calculateDistances<DIRECTION>(query_heap,
|
||||
facade,
|
||||
phantom_nodes,
|
||||
target_indices, // source_indices
|
||||
row_idx,
|
||||
source_index,
|
||||
number_of_sources,
|
||||
number_of_targets,
|
||||
search_space_with_buckets,
|
||||
distances_table,
|
||||
middle_nodes_table,
|
||||
engine_working_data);
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair(durations_table, distances_table);
|
||||
@@ -636,8 +920,12 @@ manyToManySearch(SearchEngineData<mld::Algorithm> &engine_working_data,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &source_indices,
|
||||
const std::vector<std::size_t> &target_indices,
|
||||
const bool calculate_distance)
|
||||
const bool calculate_distance,
|
||||
const bool calculate_duration)
|
||||
{
|
||||
(void)calculate_duration; // flag stub to use for calculating distances in matrix in mld in the
|
||||
// future
|
||||
|
||||
if (source_indices.size() == 1)
|
||||
{ // TODO: check if target_indices.size() == 1 and do a bi-directional search
|
||||
return mld::oneToManySearch<FORWARD_DIRECTION>(engine_working_data,
|
||||
|
||||
@@ -396,5 +396,5 @@ std::unique_ptr<SegmentDataContainer> CompressedEdgeContainer::ToSegmentData()
|
||||
|
||||
return std::move(segment_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
@@ -51,7 +51,7 @@ template <> struct hash<std::pair<NodeID, NodeID>>
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
// Buffer size of turn_indexes_write_buffer to reduce number of write(v) syscals
|
||||
const constexpr int TURN_INDEX_WRITE_BUFFER_SIZE = 1000;
|
||||
@@ -95,6 +95,12 @@ void EdgeBasedGraphFactory::GetEdgeBasedNodeSegments(std::vector<EdgeBasedNodeSe
|
||||
swap(nodes, m_edge_based_node_segments);
|
||||
}
|
||||
|
||||
void EdgeBasedGraphFactory::GetStartPointMarkers(std::vector<bool> &node_is_startpoint)
|
||||
{
|
||||
using std::swap; // Koenig swap
|
||||
swap(m_edge_based_node_is_startpoint, node_is_startpoint);
|
||||
}
|
||||
|
||||
void EdgeBasedGraphFactory::GetEdgeBasedNodeWeights(std::vector<EdgeWeight> &output_node_weights)
|
||||
{
|
||||
using std::swap; // Koenig swap
|
||||
@@ -108,13 +114,6 @@ void EdgeBasedGraphFactory::GetEdgeBasedNodeDurations(
|
||||
swap(m_edge_based_node_durations, output_node_durations);
|
||||
}
|
||||
|
||||
void EdgeBasedGraphFactory::GetEdgeBasedNodeDistances(
|
||||
std::vector<EdgeDistance> &output_node_distances)
|
||||
{
|
||||
using std::swap; // Koenig swap
|
||||
swap(m_edge_based_node_distances, output_node_distances);
|
||||
}
|
||||
|
||||
std::uint32_t EdgeBasedGraphFactory::GetConnectivityChecksum() const
|
||||
{
|
||||
return m_connectivity_checksum;
|
||||
@@ -223,9 +222,10 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
|
||||
edge_id_to_segment_id(nbe_to_ebn_mapping[edge_id_2]),
|
||||
current_edge_source_coordinate_id,
|
||||
current_edge_target_coordinate_id,
|
||||
i,
|
||||
forward_data.flags.startpoint || reverse_data.flags.startpoint);
|
||||
i);
|
||||
|
||||
m_edge_based_node_is_startpoint.push_back(forward_data.flags.startpoint ||
|
||||
reverse_data.flags.startpoint);
|
||||
current_edge_source_coordinate_id = current_edge_target_coordinate_id;
|
||||
}
|
||||
|
||||
@@ -291,12 +291,8 @@ unsigned EdgeBasedGraphFactory::LabelEdgeBasedNodes()
|
||||
{
|
||||
// heuristic: node-based graph node is a simple intersection with four edges
|
||||
// (edge-based nodes)
|
||||
constexpr std::size_t ESTIMATED_EDGE_COUNT = 4;
|
||||
m_edge_based_node_weights.reserve(ESTIMATED_EDGE_COUNT * m_node_based_graph.GetNumberOfNodes());
|
||||
m_edge_based_node_durations.reserve(ESTIMATED_EDGE_COUNT *
|
||||
m_node_based_graph.GetNumberOfNodes());
|
||||
m_edge_based_node_distances.reserve(ESTIMATED_EDGE_COUNT *
|
||||
m_node_based_graph.GetNumberOfNodes());
|
||||
m_edge_based_node_weights.reserve(4 * m_node_based_graph.GetNumberOfNodes());
|
||||
m_edge_based_node_durations.reserve(4 * m_node_based_graph.GetNumberOfNodes());
|
||||
nbe_to_ebn_mapping.resize(m_node_based_graph.GetEdgeCapacity(), SPECIAL_NODEID);
|
||||
|
||||
// renumber edge based node of outgoing edges
|
||||
@@ -314,7 +310,6 @@ unsigned EdgeBasedGraphFactory::LabelEdgeBasedNodes()
|
||||
|
||||
m_edge_based_node_weights.push_back(edge_data.weight);
|
||||
m_edge_based_node_durations.push_back(edge_data.duration);
|
||||
m_edge_based_node_distances.push_back(edge_data.distance);
|
||||
|
||||
BOOST_ASSERT(numbered_edges_count < m_node_based_graph.GetNumberOfEdges());
|
||||
nbe_to_ebn_mapping[current_edge] = numbered_edges_count;
|
||||
@@ -412,17 +407,15 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const WayRestrictionMap &way_re
|
||||
m_edge_based_node_weights.push_back(ebn_weight);
|
||||
m_edge_based_node_durations.push_back(
|
||||
m_edge_based_node_durations[nbe_to_ebn_mapping[eid]]);
|
||||
m_edge_based_node_distances.push_back(
|
||||
m_edge_based_node_distances[nbe_to_ebn_mapping[eid]]);
|
||||
|
||||
edge_based_node_id++;
|
||||
progress.PrintStatus(progress_counter++);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_ASSERT(m_edge_based_node_segments.size() == m_edge_based_node_is_startpoint.size());
|
||||
BOOST_ASSERT(m_number_of_edge_based_nodes == m_edge_based_node_weights.size());
|
||||
BOOST_ASSERT(m_number_of_edge_based_nodes == m_edge_based_node_durations.size());
|
||||
BOOST_ASSERT(m_number_of_edge_based_nodes == m_edge_based_node_distances.size());
|
||||
|
||||
util::Log() << "Generated " << m_number_of_edge_based_nodes << " nodes ("
|
||||
<< way_restriction_map.NumberOfDuplicatedNodes()
|
||||
@@ -577,7 +570,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
const auto &road_legs_on_the_right,
|
||||
const auto &road_legs_on_the_left,
|
||||
const auto &edge_geometries) {
|
||||
|
||||
const auto node_restricted =
|
||||
isRestricted(node_along_road_entering,
|
||||
intersection_node,
|
||||
@@ -701,7 +693,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
//
|
||||
tbb::filter_t<tbb::blocked_range<NodeID>, EdgesPipelineBufferPtr> processor_stage(
|
||||
tbb::filter::parallel, [&](const tbb::blocked_range<NodeID> &intersection_node_range) {
|
||||
|
||||
auto buffer = std::make_shared<EdgesPipelineBuffer>();
|
||||
buffer->nodes_processed = intersection_node_range.size();
|
||||
|
||||
@@ -1040,7 +1031,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
std::vector<EdgeWithData> delayed_data;
|
||||
tbb::filter_t<EdgesPipelineBufferPtr, void> output_stage(
|
||||
tbb::filter::serial_in_order, [&](auto buffer) {
|
||||
|
||||
routing_progress.PrintAddition(buffer->nodes_processed);
|
||||
|
||||
m_connectivity_checksum = buffer->checksum.update_checksum(m_connectivity_checksum);
|
||||
|
||||
@@ -99,7 +99,7 @@ inline NodeID mapExternalToInternalNodeID(Iter first, Iter last, const OSMNodeID
|
||||
return (it == last || value < *it) ? SPECIAL_NODEID
|
||||
: static_cast<NodeID>(std::distance(first, it));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -744,7 +744,6 @@ void ExtractionContainers::PrepareManeuverOverrides()
|
||||
**/
|
||||
auto const find_turn_from_way_tofrom_nodes = [&](auto const &from_segment,
|
||||
auto const &to_segment) {
|
||||
|
||||
if (from_segment.first_segment_source_id == to_segment.first_segment_source_id)
|
||||
{
|
||||
return NodeBasedTurn{osm_node_to_internal_nbn(from_segment.first_segment_target_id),
|
||||
@@ -861,7 +860,6 @@ void ExtractionContainers::PrepareManeuverOverrides()
|
||||
// Later, the UnresolvedManeuverOverride will be converted into a final ManeuverOverride
|
||||
// once the edge-based-node IDs are generated by the edge-based-graph-factory
|
||||
const auto transform = [&](const auto &external, auto &internal) {
|
||||
|
||||
// Create a stub override
|
||||
auto maneuver_override =
|
||||
UnresolvedManeuverOverride{{},
|
||||
|
||||
+25
-16
@@ -239,9 +239,9 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
EdgeBasedNodeDataContainer edge_based_nodes_container;
|
||||
std::vector<EdgeBasedNodeSegment> edge_based_node_segments;
|
||||
util::DeallocatingVector<EdgeBasedEdge> edge_based_edge_list;
|
||||
std::vector<bool> node_is_startpoint;
|
||||
std::vector<EdgeWeight> edge_based_node_weights;
|
||||
std::vector<EdgeDuration> edge_based_node_durations;
|
||||
std::vector<EdgeDistance> edge_based_node_distances;
|
||||
std::uint32_t ebg_connectivity_checksum = 0;
|
||||
|
||||
// Create a node-based graph from the OSRM file
|
||||
@@ -319,9 +319,9 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
scripting_environment,
|
||||
edge_based_nodes_container,
|
||||
edge_based_node_segments,
|
||||
node_is_startpoint,
|
||||
edge_based_node_weights,
|
||||
edge_based_node_durations,
|
||||
edge_based_node_distances,
|
||||
edge_based_edge_list,
|
||||
ebg_connectivity_checksum);
|
||||
|
||||
@@ -345,10 +345,8 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
|
||||
util::Log() << "Saving edge-based node weights to file.";
|
||||
TIMER_START(timer_write_node_weights);
|
||||
extractor::files::writeEdgeBasedNodeWeightsDurationsDistances(config.GetPath(".osrm.enw"),
|
||||
edge_based_node_weights,
|
||||
edge_based_node_durations,
|
||||
edge_based_node_distances);
|
||||
extractor::files::writeEdgeBasedNodeWeightsDurations(
|
||||
config.GetPath(".osrm.enw"), edge_based_node_weights, edge_based_node_durations);
|
||||
TIMER_STOP(timer_write_node_weights);
|
||||
util::Log() << "Done writing. (" << TIMER_SEC(timer_write_node_weights) << ")";
|
||||
|
||||
@@ -360,7 +358,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
|
||||
util::Log() << "Building r-tree ...";
|
||||
TIMER_START(rtree);
|
||||
BuildRTree(std::move(edge_based_node_segments), coordinates);
|
||||
BuildRTree(std::move(edge_based_node_segments), std::move(node_is_startpoint), coordinates);
|
||||
|
||||
TIMER_STOP(rtree);
|
||||
|
||||
@@ -735,9 +733,9 @@ EdgeID Extractor::BuildEdgeExpandedGraph(
|
||||
// output data
|
||||
EdgeBasedNodeDataContainer &edge_based_nodes_container,
|
||||
std::vector<EdgeBasedNodeSegment> &edge_based_node_segments,
|
||||
std::vector<bool> &node_is_startpoint,
|
||||
std::vector<EdgeWeight> &edge_based_node_weights,
|
||||
std::vector<EdgeDuration> &edge_based_node_durations,
|
||||
std::vector<EdgeDistance> &edge_based_node_distances,
|
||||
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
|
||||
std::uint32_t &connectivity_checksum)
|
||||
{
|
||||
@@ -785,9 +783,9 @@ EdgeID Extractor::BuildEdgeExpandedGraph(
|
||||
|
||||
edge_based_graph_factory.GetEdgeBasedEdges(edge_based_edge_list);
|
||||
edge_based_graph_factory.GetEdgeBasedNodeSegments(edge_based_node_segments);
|
||||
edge_based_graph_factory.GetStartPointMarkers(node_is_startpoint);
|
||||
edge_based_graph_factory.GetEdgeBasedNodeWeights(edge_based_node_weights);
|
||||
edge_based_graph_factory.GetEdgeBasedNodeDurations(edge_based_node_durations);
|
||||
edge_based_graph_factory.GetEdgeBasedNodeDistances(edge_based_node_distances);
|
||||
connectivity_checksum = edge_based_graph_factory.GetConnectivityChecksum();
|
||||
|
||||
return number_of_edge_based_nodes;
|
||||
@@ -799,24 +797,35 @@ EdgeID Extractor::BuildEdgeExpandedGraph(
|
||||
Saves tree into '.ramIndex' and leaves into '.fileIndex'.
|
||||
*/
|
||||
void Extractor::BuildRTree(std::vector<EdgeBasedNodeSegment> edge_based_node_segments,
|
||||
std::vector<bool> node_is_startpoint,
|
||||
const std::vector<util::Coordinate> &coordinates)
|
||||
{
|
||||
util::Log() << "Constructing r-tree of " << edge_based_node_segments.size()
|
||||
<< " segments build on-top of " << coordinates.size() << " coordinates";
|
||||
|
||||
BOOST_ASSERT(node_is_startpoint.size() == edge_based_node_segments.size());
|
||||
|
||||
// Filter node based edges based on startpoint
|
||||
auto start_point_count = std::accumulate(edge_based_node_segments.begin(),
|
||||
edge_based_node_segments.end(),
|
||||
0,
|
||||
[](const size_t so_far, const auto &segment) {
|
||||
return so_far + (segment.is_startpoint ? 1 : 0);
|
||||
});
|
||||
if (start_point_count == 0)
|
||||
auto out_iter = edge_based_node_segments.begin();
|
||||
auto in_iter = edge_based_node_segments.begin();
|
||||
for (auto index : util::irange<std::size_t>(0UL, node_is_startpoint.size()))
|
||||
{
|
||||
BOOST_ASSERT(in_iter != edge_based_node_segments.end());
|
||||
if (node_is_startpoint[index])
|
||||
{
|
||||
*out_iter = *in_iter;
|
||||
out_iter++;
|
||||
}
|
||||
in_iter++;
|
||||
}
|
||||
auto new_size = out_iter - edge_based_node_segments.begin();
|
||||
if (new_size == 0)
|
||||
{
|
||||
throw util::exception("There are no snappable edges left after processing. Are you "
|
||||
"setting travel modes correctly in the profile? Cannot continue." +
|
||||
SOURCE_REF);
|
||||
}
|
||||
edge_based_node_segments.resize(new_size);
|
||||
|
||||
TIMER_START(construction);
|
||||
util::StaticRTree<EdgeBasedNodeSegment> rtree(
|
||||
|
||||
@@ -259,6 +259,7 @@ void GraphCompressor::Compress(
|
||||
const auto forward_weight2 = fwd_edge_data2.weight;
|
||||
const auto forward_duration1 = fwd_edge_data1.duration;
|
||||
const auto forward_duration2 = fwd_edge_data2.duration;
|
||||
// const auto forward_distance1 = fwd_edge_data1.distance;
|
||||
const auto forward_distance2 = fwd_edge_data2.distance;
|
||||
|
||||
BOOST_ASSERT(0 != forward_weight1);
|
||||
@@ -268,18 +269,9 @@ void GraphCompressor::Compress(
|
||||
const auto reverse_weight2 = rev_edge_data2.weight;
|
||||
const auto reverse_duration1 = rev_edge_data1.duration;
|
||||
const auto reverse_duration2 = rev_edge_data2.duration;
|
||||
// const auto reverse_distance1 = rev_edge_data1.distance;
|
||||
const auto reverse_distance2 = rev_edge_data2.distance;
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Because distances are symmetrical, we only need one
|
||||
// per edge - here we double-check that they match
|
||||
// their mirrors.
|
||||
const auto reverse_distance1 = rev_edge_data1.distance;
|
||||
const auto forward_distance1 = fwd_edge_data1.distance;
|
||||
BOOST_ASSERT(forward_distance1 == reverse_distance2);
|
||||
BOOST_ASSERT(forward_distance2 == reverse_distance1);
|
||||
#endif
|
||||
|
||||
BOOST_ASSERT(0 != reverse_weight1);
|
||||
BOOST_ASSERT(0 != reverse_weight2);
|
||||
|
||||
@@ -291,7 +283,7 @@ void GraphCompressor::Compress(
|
||||
graph.GetEdgeData(forward_e1).duration += forward_duration2;
|
||||
graph.GetEdgeData(reverse_e1).duration += reverse_duration2;
|
||||
|
||||
// add distance of e2's to e1
|
||||
// add duration of e2's to e1
|
||||
graph.GetEdgeData(forward_e1).distance += forward_distance2;
|
||||
graph.GetEdgeData(reverse_e1).distance += reverse_distance2;
|
||||
|
||||
@@ -376,5 +368,5 @@ void GraphCompressor::PrintStatistics(unsigned original_number_of_nodes,
|
||||
util::Log() << "Node compression ratio: " << new_node_count / (double)original_number_of_nodes;
|
||||
util::Log() << "Edge compression ratio: " << new_edge_count / (double)original_number_of_edges;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user