Skip to content

Commit 2e54842

Browse files
Merge branch 'master' into sf-ankerl
2 parents cf4141d + c7ee1a5 commit 2e54842

38 files changed

+355
-234
lines changed

.github/workflows/osrm-backend.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,11 @@ jobs:
377377
key: v4-test-${{ matrix.name }}-${{ github.sha }}
378378
restore-keys: |
379379
v4-test-${{ matrix.name }}-
380-
381380
- name: Prepare environment
382381
run: |
383382
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
384383
mkdir -p $HOME/.ccache
385-
384+
386385
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
387386
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
388387
echo "OSRM_INSTALL_DIR=${GITHUB_WORKSPACE}/install-osrm" >> $GITHUB_ENV
@@ -490,7 +489,7 @@ jobs:
490489
run: |
491490
echo "Using ${JOBS} jobs"
492491
pushd ${OSRM_BUILD_DIR}
493-
492+
494493
ccache --zero-stats
495494
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
496495
-DENABLE_CONAN=${ENABLE_CONAN:-OFF} \
@@ -508,6 +507,7 @@ jobs:
508507
if [[ "${NODE_PACKAGE_TESTS_ONLY}" != "ON" ]]; then
509508
make tests --jobs=${JOBS}
510509
make benchmarks --jobs=${JOBS}
510+
511511
sudo make install
512512
if [[ "${RUNNER_OS}" == "Linux" ]]; then
513513
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OSRM_INSTALL_DIR}/lib" >> $GITHUB_ENV
@@ -628,6 +628,13 @@ jobs:
628628
PR_NUMBER: ${{ github.event.pull_request.number }}
629629
GITHUB_REPOSITORY: ${{ github.repository }}
630630
steps:
631+
- name: Enable data.osm.pbf cache
632+
uses: actions/cache@v4
633+
with:
634+
path: ~/data.osm.pbf
635+
key: v1-data-osm-pbf
636+
restore-keys: |
637+
v1-data-osm-pbf
631638
- name: Enable compiler cache
632639
uses: actions/cache@v4
633640
with:
@@ -648,9 +655,15 @@ jobs:
648655
ref: ${{ github.head_ref }}
649656
path: pr
650657
- name: Install dependencies
651-
run: |
652-
python3 -m pip install "conan<2.0.0" "requests==2.31.0"
658+
run: |
659+
python3 -m pip install "conan<2.0.0" "requests==2.31.0" "locust==2.28.0"
653660
sudo apt-get update -y && sudo apt-get install ccache
661+
- name: Prepare data
662+
run: |
663+
if [ ! -f "~/data.osm.pbf" ]; then
664+
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf -O ~/data.osm.pbf
665+
fi
666+
gunzip -c ./pr/test/data/berlin_gps_traces.csv.gz > ~/gps_traces.csv
654667
- name: Prepare environment
655668
run: |
656669
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Unreleased
22
- Changes from 5.27.1
33
- Features
4+
- REMOVED: Remove all core-CH left-overs [#6920](https://github.com/Project-OSRM/osrm-backend/pull/6920)
45
- ADDED: Add support for a keepalive_timeout flag. [#6674](https://github.com/Project-OSRM/osrm-backend/pull/6674)
56
- ADDED: Add support for a default_radius flag. [#6575](https://github.com/Project-OSRM/osrm-backend/pull/6575)
67
- ADDED: Add support for disabling feature datasets. [#6666](https://github.com/Project-OSRM/osrm-backend/pull/6666)
@@ -22,6 +23,9 @@
2223
- NodeJS:
2324
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
2425
- Misc:
26+
- CHANGED: Use custom struct instead of std::pair in QueryHeap. [#6921](https://github.com/Project-OSRM/osrm-backend/pull/6921)
27+
- CHANGED: Use std::string_view::starts_with instead of boost::starts_with. [#6918](https://github.com/Project-OSRM/osrm-backend/pull/6918)
28+
- CHANGED: Get rid of boost::math::constants::* and M_PI in favor of std::numbers. [#6916](https://github.com/Project-OSRM/osrm-backend/pull/6916)
2529
- CHANGED: Make constants in PackedVector constexpr. [#6917](https://github.com/Project-OSRM/osrm-backend/pull/6917)
2630
- CHANGED: Use std::variant instead of mapbox::util::variant. [#6903](https://github.com/Project-OSRM/osrm-backend/pull/6903)
2731
- CHANGED: Bump rapidjson to version f9d53419e912910fd8fa57d5705fa41425428c35 [#6906](https://github.com/Project-OSRM/osrm-backend/pull/6906)

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
266266
add_dependency_defines(-DBOOST_LIB_DIAGNOSTIC)
267267
add_dependency_defines(-D_CRT_SECURE_NO_WARNINGS)
268268
add_dependency_defines(-DNOMINMAX) # avoid min and max macros that can break compilation
269-
add_dependency_defines(-D_USE_MATH_DEFINES) #needed for M_PI with cmath.h
270269
add_dependency_defines(-D_WIN32_WINNT=0x0501)
271270
add_dependency_defines(-DXML_STATIC)
272271
find_library(ws2_32_LIBRARY_PATH ws2_32)

docs/nodejs/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var osrm = new OSRM('network.osrm');
2121
**Parameters**
2222

2323
- `options` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))** Options for creating an OSRM object or string to the `.osrm` file. (optional, default `{shared_memory:true}`)
24-
- `options.algorithm` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** The algorithm to use for routing. Can be 'CH', 'CoreCH' or 'MLD'. Default is 'CH'.
24+
- `options.algorithm` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** The algorithm to use for routing. Can be 'CH', or 'MLD'. Default is 'CH'.
2525
Make sure you prepared the dataset with the correct toolchain.
2626
- `options.shared_memory` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Connects to the persistent shared memory datastore.
2727
This requires you to run `osrm-datastore` prior to creating an `OSRM` object.

include/engine/engine_config.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,10 @@ namespace osrm::engine
5454
*
5555
* In addition, shared memory can be used for datasets loaded with osrm-datastore.
5656
*
57-
* You can chose between three algorithms:
57+
* You can chose between two algorithms:
5858
* - Algorithm::CH
5959
* Contraction Hierarchies, extremely fast queries but slow pre-processing. The default right
6060
* now.
61-
* - Algorithm::CoreCH
62-
* Deprecated, to be removed in v6.0
63-
* Contraction Hierachies with partial contraction for faster pre-processing but slower
64-
* queries.
6561
* - Algorithm::MLD
6662
* Multi Level Dijkstra, moderately fast in both pre-processing and query.
6763
*
@@ -74,7 +70,6 @@ struct EngineConfig final
7470
enum class Algorithm
7571
{
7672
CH,
77-
CoreCH, // Deprecated, will be removed in v6.0
7873
MLD
7974
};
8075

include/engine/map_matching/bayes_classifier.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <utility>
77
#include <vector>
88

9-
#include <boost/math/constants/constants.hpp>
9+
#include <numbers>
1010

1111
namespace osrm::engine::map_matching
1212
{
@@ -21,10 +21,8 @@ struct NormalDistribution
2121
// FIXME implement log-probability version since it's faster
2222
double Density(const double val) const
2323
{
24-
using namespace boost::math::constants;
25-
2624
const double x = val - mean;
27-
return 1.0 / (std::sqrt(two_pi<double>()) * standard_deviation) *
25+
return 1.0 / (std::sqrt(2 * std::numbers::pi) * standard_deviation) *
2826
std::exp(-x * x / (standard_deviation * standard_deviation));
2927
}
3028

include/engine/map_matching/hidden_markov_model.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "util/integer_range.hpp"
55

66
#include <boost/assert.hpp>
7-
#include <boost/math/constants/constants.hpp>
7+
#include <numbers>
88

99
#include <cmath>
1010

@@ -14,7 +14,7 @@
1414
namespace osrm::engine::map_matching
1515
{
1616

17-
static const double log_2_pi = std::log(2. * boost::math::constants::pi<double>());
17+
static const double log_2_pi = std::log(2. * std::numbers::pi);
1818
static const double IMPOSSIBLE_LOG_PROB = -std::numeric_limits<double>::infinity();
1919
static const double MINIMAL_LOG_PROB = std::numeric_limits<double>::lowest();
2020
static const std::size_t INVALID_STATE = std::numeric_limits<std::size_t>::max();

include/engine/map_matching/matching_confidence.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define ENGINE_MAP_MATCHING_CONFIDENCE_HPP
33

44
#include "engine/map_matching/bayes_classifier.hpp"
5-
5+
#include <boost/assert.hpp>
66
#include <cmath>
77

88
namespace osrm::engine::map_matching

include/engine/search_engine_data.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace osrm::engine
1212

1313
// Algorithm-dependent heaps
1414
// - CH algorithms use CH heaps
15-
// - CoreCH algorithms use CH
1615
// - MLD algorithms use MLD heaps
1716

1817
template <typename Algorithm> struct SearchEngineData

include/nodejs/node_osrm_support.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,24 +296,19 @@ inline engine_config_ptr argumentsToEngineConfig(const Napi::CallbackInfo &args)
296296
{
297297
engine_config->algorithm = osrm::EngineConfig::Algorithm::CH;
298298
}
299-
else if (algorithm_str == "CoreCH")
300-
{
301-
engine_config->algorithm = osrm::EngineConfig::Algorithm::CH;
302-
}
303299
else if (algorithm_str == "MLD")
304300
{
305301
engine_config->algorithm = osrm::EngineConfig::Algorithm::MLD;
306302
}
307303
else
308304
{
309-
ThrowError(args.Env(), "algorithm option must be one of 'CH', 'CoreCH', or 'MLD'.");
305+
ThrowError(args.Env(), "algorithm option must be one of 'CH', or 'MLD'.");
310306
return engine_config_ptr();
311307
}
312308
}
313309
else if (!algorithm.IsUndefined())
314310
{
315-
ThrowError(args.Env(),
316-
"algorithm option must be a string and one of 'CH', 'CoreCH', or 'MLD'.");
311+
ThrowError(args.Env(), "algorithm option must be a string and one of 'CH', or 'MLD'.");
317312
return engine_config_ptr();
318313
}
319314

include/util/cheap_ruler.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <cmath>
55
#include <cstdint>
66
#include <limits>
7+
#include <numbers>
78
#include <tuple>
89
#include <utility>
910

@@ -37,7 +38,7 @@ class CheapRuler
3738
static constexpr double FE = 1.0 / 298.257223563; // flattening
3839

3940
static constexpr double E2 = FE * (2 - FE);
40-
static constexpr double RAD = M_PI / 180.0;
41+
static constexpr double RAD = std::numbers::pi / 180.0;
4142

4243
public:
4344
explicit CheapRuler(double latitude)

include/util/coordinate_calculation.hpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "util/coordinate.hpp"
55

6-
#include <boost/math/constants/constants.hpp>
6+
#include <numbers>
77

88
#include <algorithm>
99
#include <cmath>
@@ -23,17 +23,9 @@ const constexpr double RAD_TO_DEGREE = 1. / DEGREE_TO_RAD;
2323
// The IUGG value for the equatorial radius is 6378.137 km (3963.19 miles)
2424
const constexpr long double EARTH_RADIUS = 6372797.560856;
2525

26-
inline double degToRad(const double degree)
27-
{
28-
using namespace boost::math::constants;
29-
return degree * (pi<double>() / 180.0);
30-
}
26+
inline double degToRad(const double degree) { return degree * (std::numbers::pi / 180.0); }
3127

32-
inline double radToDeg(const double radian)
33-
{
34-
using namespace boost::math::constants;
35-
return radian * (180.0 * (1. / pi<double>()));
36-
}
28+
inline double radToDeg(const double radian) { return radian * (180.0 * std::numbers::inv_pi); }
3729
} // namespace detail
3830

3931
const constexpr static double METERS_PER_DEGREE_LAT = 110567.0;

include/util/guidance/name_announcements.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#include "util/typedefs.hpp"
1010

11-
#include <boost/algorithm/string.hpp>
12-
1311
#include <algorithm>
1412
#include <string>
1513
#include <tuple>
@@ -126,8 +124,7 @@ inline bool requiresNameAnnounced(const StringView &from_name,
126124

127125
// check similarity of names
128126
const auto names_are_empty = from_name.empty() && to_name.empty();
129-
const auto name_is_contained =
130-
boost::starts_with(from_name, to_name) || boost::starts_with(to_name, from_name);
127+
const auto name_is_contained = from_name.starts_with(to_name) || to_name.starts_with(from_name);
131128

132129
const auto checkForPrefixOrSuffixChange = [](const std::string_view first,
133130
const std::string_view second,

include/util/query_heap.hpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,20 @@ template <typename NodeID,
156156
class QueryHeap
157157
{
158158
private:
159-
using HeapData = std::pair<Weight, Key>;
159+
struct HeapData
160+
{
161+
Weight weight;
162+
Key index;
163+
164+
bool operator>(const HeapData &other) const
165+
{
166+
if (weight == other.weight)
167+
{
168+
return index > other.index;
169+
}
170+
return weight > other.weight;
171+
}
172+
};
160173
using HeapContainer = boost::heap::d_ary_heap<HeapData,
161174
boost::heap::arity<4>,
162175
boost::heap::mutable_<true>,
@@ -195,7 +208,7 @@ class QueryHeap
195208
{
196209
BOOST_ASSERT(node < std::numeric_limits<NodeID>::max());
197210
const auto index = static_cast<Key>(inserted_nodes.size());
198-
const auto handle = heap.push(std::make_pair(weight, index));
211+
const auto handle = heap.emplace(HeapData{weight, index});
199212
inserted_nodes.emplace_back(HeapNode{handle, node, weight, data});
200213
node_index[node] = index;
201214
}
@@ -278,19 +291,19 @@ class QueryHeap
278291
NodeID Min() const
279292
{
280293
BOOST_ASSERT(!heap.empty());
281-
return inserted_nodes[heap.top().second].node;
294+
return inserted_nodes[heap.top().index].node;
282295
}
283296

284297
Weight MinKey() const
285298
{
286299
BOOST_ASSERT(!heap.empty());
287-
return heap.top().first;
300+
return heap.top().weight;
288301
}
289302

290303
NodeID DeleteMin()
291304
{
292305
BOOST_ASSERT(!heap.empty());
293-
const Key removedIndex = heap.top().second;
306+
const Key removedIndex = heap.top().index;
294307
heap.pop();
295308
inserted_nodes[removedIndex].handle = heap.s_handle_from_iterator(heap.end());
296309
return inserted_nodes[removedIndex].node;
@@ -299,7 +312,7 @@ class QueryHeap
299312
HeapNode &DeleteMinGetHeapNode()
300313
{
301314
BOOST_ASSERT(!heap.empty());
302-
const Key removedIndex = heap.top().second;
315+
const Key removedIndex = heap.top().index;
303316
heap.pop();
304317
inserted_nodes[removedIndex].handle = heap.s_handle_from_iterator(heap.end());
305318
return inserted_nodes[removedIndex];
@@ -320,13 +333,13 @@ class QueryHeap
320333
const auto index = node_index.peek_index(node);
321334
auto &reference = inserted_nodes[index];
322335
reference.weight = weight;
323-
heap.increase(reference.handle, std::make_pair(weight, index));
336+
heap.increase(reference.handle, HeapData{weight, static_cast<Key>(index)});
324337
}
325338

326339
void DecreaseKey(const HeapNode &heapNode)
327340
{
328341
BOOST_ASSERT(!WasRemoved(heapNode.node));
329-
heap.increase(heapNode.handle, std::make_pair(heapNode.weight, (*heapNode.handle).second));
342+
heap.increase(heapNode.handle, HeapData{heapNode.weight, (*heapNode.handle).index});
330343
}
331344

332345
private:

0 commit comments

Comments
 (0)