Skip to content

Commit 09ff160

Browse files
committed
Revert previous commits for cleaner approach
1 parent 7dfa2bd commit 09ff160

File tree

18 files changed

+82
-229
lines changed

18 files changed

+82
-229
lines changed

CHANGELOG.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Unreleased
22
- Changes from 5.27.1
3-
- API:
4-
- CHANGED: Require a `radius` parameter when using `bearings`. [#6572](https://github.com/Project-OSRM/osrm-backend/pull/6572)
53
- Build:
64
- ADDED: Add CI job which builds OSRM with gcc 12. [#6455](https://github.com/Project-OSRM/osrm-backend/pull/6455)
75
- CHANGED: Upgrade to clang-tidy 15. [#6439](https://github.com/Project-OSRM/osrm-backend/pull/6439)

docs/http.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To pass parameters to each location some options support an array-like encoding:
3131

3232
| Option | Values | Description |
3333
|----------------|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
34-
|bearings |`{bearing};{bearing}[;{bearing} ...]` |Limits the search to segments with given bearing in degrees towards true north in a clockwise direction. Requires a corresponding radius. |
34+
|bearings |`{bearing};{bearing}[;{bearing} ...]` |Limits the search to segments with given bearing in degrees towards true north in a clockwise direction. |
3535
|radiuses |`{radius};{radius}[;{radius} ...]` |Limits the search to given radius in meters. |
3636
|generate\_hints |`true` (default), `false` |Adds a Hint to the response which can be used in subsequent requests, see `hints` parameter. |
3737
|hints |`{hint};{hint}[;{hint} ...]` |Hint from previous request to derive position in street network. |

docs/nodejs/api.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ var osrm = new OSRM('network.osrm');
111111
var options = {
112112
coordinates: [[13.388860,52.517037]],
113113
number: 3,
114-
bearings: [[0,20]],
115-
radiuses: [null]
114+
bearings: [[0,20]]
116115
};
117116
osrm.nearest(options, function(err, response) {
118117
console.log(response.waypoints); // array of Waypoint objects

features/car/startpoint.feature

-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ Feature: Car - Allowed start/end modes
7070
Given the query options
7171
| snapping | any |
7272
| bearings | 90,180; |
73-
| radiuses | unlimited; |
7473

7574
And the ways
7675
| nodes | highway | access |
@@ -113,7 +112,6 @@ Feature: Car - Allowed start/end modes
113112
Given the query options
114113
| snapping | any |
115114
| bearings | 90,180;0,180;; |
116-
| radiuses | unlimited;;; |
117115

118116
And the ways
119117
| nodes | highway | access |

features/support/route.js

-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ module.exports = function () {
6666
if (bs.length === 2) return b;
6767
else return b += ',10';
6868
}).join(';');
69-
params.radiuses = bearings.map(() => {
70-
return 'unlimited';
71-
}).join(';');
7269
}
7370

7471
if (approaches.length) {

features/testbot/annotations.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ Feature: Annotations
112112
And the query options
113113
| annotations | speed,distance,duration,nodes |
114114
| bearings | 90,5;180,5 |
115-
| radiuses | unlimited;unlimited |
116115

117116
When I route I should get
118-
| from | to | route | a:speed | a:distance | a:duration | a:nodes |
117+
| from | to | route | a:speed | a:distance | a:duration | a:nodes |
119118
| a | c | abc,abc | 10:10 | 249.9876189:299.962882 | 25:30 | 1:2:3 |

include/engine/api/base_parameters.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct BaseParameters
106106
bool IsValid() const
107107
{
108108
return (hints.empty() || hints.size() == coordinates.size()) &&
109-
(bearings.empty() || bearings.size() == radiuses.size()) &&
109+
(bearings.empty() || bearings.size() == coordinates.size()) &&
110110
(radiuses.empty() || radiuses.size() == coordinates.size()) &&
111111
(approaches.empty() || approaches.size() == coordinates.size()) &&
112112
std::all_of(bearings.begin(),

include/nodejs/node_osrm_support.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -522,12 +522,6 @@ inline bool argumentsToParameter(const Napi::CallbackInfo &args,
522522
if (bearings.IsEmpty())
523523
return false;
524524

525-
if (!obj.Has("radiuses"))
526-
{
527-
ThrowError(args.Env(), "Bearings must be accompanied with radiuses");
528-
return false;
529-
}
530-
531525
if (!bearings.IsArray())
532526
{
533527
ThrowError(args.Env(), "Bearings must be an array of arrays of numbers");

include/server/service/utils.hpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@ namespace osrm::server::service
44
{
55

66
const constexpr char PARAMETER_SIZE_MISMATCH_MSG[] =
7-
"Number of elements in %1% size %2% does not match %3% size %4%";
7+
"Number of elements in %1% size %2% does not match coordinate size %3%";
88

99
template <typename ParamT>
1010
bool constrainParamSize(const char *msg_template,
11-
const char *param_name,
11+
const char *name,
1212
const ParamT &param,
13-
const char *target_name,
1413
const std::size_t target_size,
1514
std::string &help)
1615
{
1716
if (param.size() > 0 && param.size() != target_size)
1817
{
19-
help = (boost::format(msg_template) % param_name % param.size() % target_name % target_size)
20-
.str();
18+
help = (boost::format(msg_template) % name % param.size() % target_size).str();
2119
return true;
2220
}
2321
return false;

src/engine/plugins/table.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
4343
"InvalidOptions", "Number of bearings does not match number of coordinates", result);
4444
}
4545

46-
if (!params.bearings.empty() && params.radiuses.size() != params.bearings.size())
47-
{
48-
return Error(
49-
"InvalidOptions", "Number of radiuses does not match number of bearings", result);
50-
}
51-
5246
// Empty sources or destinations means the user wants all of them included, respectively
5347
// The ManyToMany routing algorithm we dispatch to below already handles this perfectly.
5448
const auto num_sources =

src/nodejs/node_osrm.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,7 @@ Napi::Value Engine::route(const Napi::CallbackInfo &info)
349349
* var options = {
350350
* coordinates: [[13.388860,52.517037]],
351351
* number: 3,
352-
* bearings: [[0,20]],
353-
* radiuses: [null]
352+
* bearings: [[0,20]]
354353
* };
355354
* osrm.nearest(options, function(err, response) {
356355
* console.log(response.waypoints); // array of Waypoint objects

src/server/service/match_service.cpp

+12-32
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#include "server/service/match_service.hpp"
2-
#include "server/service/utils.hpp"
32

43
#include "server/api/parameters_parser.hpp"
4+
#include "server/service/utils.hpp"
55
#include "engine/api/match_parameters.hpp"
66

77
#include "util/json_container.hpp"
88

9+
#include <boost/format.hpp>
10+
911
namespace osrm::server::service
1012
{
1113
namespace
@@ -15,38 +17,16 @@ std::string getWrongOptionHelp(const engine::api::MatchParameters &parameters)
1517
std::string help;
1618

1719
const auto coord_size = parameters.coordinates.size();
18-
const auto bearings_size = parameters.bearings.size();
1920

20-
const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
21-
"hints",
22-
parameters.hints,
23-
"coordinates",
24-
coord_size,
25-
help) ||
26-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
27-
"bearings",
28-
parameters.bearings,
29-
"coordinates",
30-
coord_size,
31-
help) ||
32-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
33-
"radiuses",
34-
parameters.radiuses,
35-
"bearings",
36-
bearings_size,
37-
help) ||
38-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
39-
"radiuses",
40-
parameters.radiuses,
41-
"coordinates",
42-
coord_size,
43-
help) ||
44-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
45-
"timestamps",
46-
parameters.timestamps,
47-
"coordinates",
48-
coord_size,
49-
help);
21+
const bool param_size_mismatch =
22+
constrainParamSize(
23+
PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) ||
24+
constrainParamSize(
25+
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) ||
26+
constrainParamSize(
27+
PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help) ||
28+
constrainParamSize(
29+
PARAMETER_SIZE_MISMATCH_MSG, "timestamps", parameters.timestamps, coord_size, help);
5030

5131
if (!param_size_mismatch && parameters.coordinates.size() < 2)
5232
{

src/server/service/nearest_service.cpp

+9-26
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,26 @@
66

77
#include "util/json_container.hpp"
88

9+
#include <boost/format.hpp>
10+
911
namespace osrm::server::service
1012
{
13+
1114
namespace
1215
{
1316
std::string getWrongOptionHelp(const engine::api::NearestParameters &parameters)
1417
{
1518
std::string help;
1619

1720
const auto coord_size = parameters.coordinates.size();
18-
const auto bearings_size = parameters.bearings.size();
1921

22+
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help);
23+
constrainParamSize(
24+
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help);
25+
constrainParamSize(
26+
PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help);
2027
constrainParamSize(
21-
PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, "coordinates", coord_size, help);
22-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
23-
"bearings",
24-
parameters.bearings,
25-
"coordinates",
26-
coord_size,
27-
help);
28-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
29-
"radiuses",
30-
parameters.radiuses,
31-
"bearings",
32-
bearings_size,
33-
help);
34-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
35-
"radiuses",
36-
parameters.radiuses,
37-
"coordinates",
38-
coord_size,
39-
help);
40-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
41-
"approaches",
42-
parameters.approaches,
43-
"coordinates",
44-
coord_size,
45-
help);
28+
PARAMETER_SIZE_MISMATCH_MSG, "approaches", parameters.approaches, coord_size, help);
4629

4730
return help;
4831
}

src/server/service/route_service.cpp

+9-31
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,16 @@ std::string getWrongOptionHelp(const engine::api::RouteParameters &parameters)
1515
std::string help;
1616

1717
const auto coord_size = parameters.coordinates.size();
18-
const auto bearings_size = parameters.bearings.size();
1918

20-
const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
21-
"hints",
22-
parameters.hints,
23-
"coordinates",
24-
coord_size,
25-
help) ||
26-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
27-
"bearings",
28-
parameters.bearings,
29-
"coordinates",
30-
coord_size,
31-
help) ||
32-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
33-
"radiuses",
34-
parameters.radiuses,
35-
"bearings",
36-
bearings_size,
37-
help) ||
38-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
39-
"radiuses",
40-
parameters.radiuses,
41-
"coordinates",
42-
coord_size,
43-
help) ||
44-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
45-
"approaches",
46-
parameters.approaches,
47-
"coordinates",
48-
coord_size,
49-
help);
19+
const bool param_size_mismatch =
20+
constrainParamSize(
21+
PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) ||
22+
constrainParamSize(
23+
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) ||
24+
constrainParamSize(
25+
PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help) ||
26+
constrainParamSize(
27+
PARAMETER_SIZE_MISMATCH_MSG, "approaches", parameters.approaches, coord_size, help);
5028

5129
if (!param_size_mismatch && parameters.coordinates.size() < 2)
5230
{

src/server/service/table_service.cpp

+32-33
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,51 @@
11
#include "server/service/table_service.hpp"
2-
#include "server/service/utils.hpp"
32

43
#include "server/api/parameters_parser.hpp"
54
#include "engine/api/table_parameters.hpp"
65

76
#include "util/json_container.hpp"
87

8+
#include <boost/format.hpp>
9+
910
namespace osrm::server::service
1011
{
12+
1113
namespace
1214
{
15+
16+
const constexpr char PARAMETER_SIZE_MISMATCH_MSG[] =
17+
"Number of elements in %1% size %2% does not match coordinate size %3%";
18+
19+
template <typename ParamT>
20+
bool constrainParamSize(const char *msg_template,
21+
const char *name,
22+
const ParamT &param,
23+
const std::size_t target_size,
24+
std::string &help)
25+
{
26+
if (param.size() > 0 && param.size() != target_size)
27+
{
28+
help = (boost::format(msg_template) % name % param.size() % target_size).str();
29+
return true;
30+
}
31+
return false;
32+
}
33+
1334
std::string getWrongOptionHelp(const engine::api::TableParameters &parameters)
1435
{
1536
std::string help;
1637

1738
const auto coord_size = parameters.coordinates.size();
18-
const auto bearings_size = parameters.bearings.size();
19-
20-
const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
21-
"hints",
22-
parameters.hints,
23-
"coordinates",
24-
coord_size,
25-
help) ||
26-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
27-
"bearings",
28-
parameters.bearings,
29-
"coordinates",
30-
coord_size,
31-
help) ||
32-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
33-
"radiuses",
34-
parameters.radiuses,
35-
"bearings",
36-
bearings_size,
37-
help) ||
38-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
39-
"radiuses",
40-
parameters.radiuses,
41-
"coordinates",
42-
coord_size,
43-
help) ||
44-
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG,
45-
"approaches",
46-
parameters.approaches,
47-
"coordinates",
48-
coord_size,
49-
help);
39+
40+
const bool param_size_mismatch =
41+
constrainParamSize(
42+
PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) ||
43+
constrainParamSize(
44+
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) ||
45+
constrainParamSize(
46+
PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help) ||
47+
constrainParamSize(
48+
PARAMETER_SIZE_MISMATCH_MSG, "approaches", parameters.approaches, coord_size, help);
5049

5150
if (!param_size_mismatch && parameters.coordinates.size() < 2)
5251
{

0 commit comments

Comments
 (0)