Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ int main(int argc, char** argv) {
cxxopts::value<unsigned>(exploration_level)->default_value(std::to_string(vroom::DEFAULT_EXPLORATION_LEVEL)))
("stdin",
"optional input positional arg",
cxxopts::value<std::string>(cl_args.input));

cxxopts::value<std::string>(cl_args.input))
("s,osrm-snapping-radius",
"set the OSRM snapping radius, in meters",
cxxopts::value<unsigned>(cl_args.osrm_snapping_radius)->default_value(vroom::DEFAULT_OSRM_SNAPPING_RADIUS));
// we don't want to print debug args on --help
options.add_options("debug_group")
("f,apply-tsp-fix",
Expand Down Expand Up @@ -149,6 +151,9 @@ int main(int argc, char** argv) {
for (const auto& port : port_args) {
vroom::io::update_port(cl_args.servers, port);
}

vroom::io::update_osrm_snap_radius(cl_args.servers, std::to_string(cl_args.osrm_snapping_radius));

exploration_level = std::min(exploration_level, vroom::MAX_EXPLORATION_LEVEL);
cl_args.set_exploration_level(exploration_level);

Expand Down
4 changes: 2 additions & 2 deletions src/routing/osrm_routed_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ OsrmRoutedWrapper::build_query(const std::vector<Location>& locations,
std::string radiuses = "radiuses=";
radiuses.reserve(radiuses.size() +
locations.size() *
(DEFAULT_OSRM_SNAPPING_RADIUS.size() + 1));
(_server.osrm_snapping_radius.size() + 1));

// Adding locations and radiuses values.
for (auto const& location : locations) {
query += std::format("{:.6f},{:.6f};", location.lon(), location.lat());
radiuses += DEFAULT_OSRM_SNAPPING_RADIUS + ";";
radiuses += _server.osrm_snapping_radius + ";";
}
// Remove trailing ';'.
query.pop_back();
Expand Down
6 changes: 6 additions & 0 deletions src/structures/cl_args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ void update_port(Servers& servers, std::string_view value) {
}
}

void update_osrm_snap_radius(Servers& servers, std::string_view value) {
for (auto& [profile, server] : servers) {
server.osrm_snapping_radius = value;
}
}

void CLArgs::set_exploration_level(unsigned exploration_level) {
depth = utils::get_depth(exploration_level);

Expand Down
27 changes: 15 additions & 12 deletions src/structures/cl_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ using Servers =

struct CLArgs {
// Listing command-line options.
Servers servers; // -a and -p
bool check; // -c
bool apply_TSPFix; // -f
bool geometry; // -g
std::string input_file; // -i
Timeout timeout; // -l
std::string output_file; // -o
ROUTER router; // -r
std::string input; // cl arg
unsigned nb_threads; // -t
unsigned nb_searches; // derived from -x
unsigned depth; // derived from -x
Servers servers; // -a and -p
bool check; // -c
bool apply_TSPFix; // -f
bool geometry; // -g
std::string input_file; // -i
Timeout timeout; // -l
std::string output_file; // -o
ROUTER router; // -r
std::string input; // cl arg
unsigned nb_threads; // -t
unsigned nb_searches; // derived from -x
unsigned depth; // derived from -x
unsigned osrm_snapping_radius; // -s

void set_exploration_level(unsigned exploration_level);
};
Expand All @@ -43,6 +44,8 @@ void update_host(Servers& servers, std::string_view value);

void update_port(Servers& servers, std::string_view value);

void update_osrm_snap_radius(Servers& servers, std::string_view value);

} // namespace vroom::io

#endif
1 change: 1 addition & 0 deletions src/structures/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ struct Server {
std::string host;
std::string port;
std::string path;
std::string osrm_snapping_radius;

Server() : host("0.0.0.0"), port("5000") {
}
Expand Down