diff --git a/include/engine/api/base_parameters.hpp b/include/engine/api/base_parameters.hpp index abcbe1a3edf..04865be77ee 100644 --- a/include/engine/api/base_parameters.hpp +++ b/include/engine/api/base_parameters.hpp @@ -7,6 +7,7 @@ #include #include +#include namespace osrm { @@ -32,7 +33,19 @@ struct BaseParameters { return (hints.empty() || hints.size() == coordinates.size()) && (bearings.empty() || bearings.size() == coordinates.size()) && - (radiuses.empty() || radiuses.size() == coordinates.size()); + (radiuses.empty() || radiuses.size() == coordinates.size()) && + std::all_of(bearings.begin(), bearings.end(), + [](const boost::optional bearing_and_range) + { + if (bearing_and_range) + { + return bearing_and_range->bearing >= 0 && + bearing_and_range->bearing <= 360 && + bearing_and_range->range >= 0 && + bearing_and_range->range <= 180; + } + return true; + }); } }; diff --git a/include/engine/api/json_factory.hpp b/include/engine/api/json_factory.hpp index 987ff7e4006..586ba398946 100644 --- a/include/engine/api/json_factory.hpp +++ b/include/engine/api/json_factory.hpp @@ -76,7 +76,7 @@ util::json::Object makeRoute(const guidance::Route &route, boost::optional geometry); util::json::Object -makeWaypoint(const FixedPointCoordinate location, std::string &&way_name, const Hint &hint); +makeWaypoint(const FixedPointCoordinate location, std::string &&name, const Hint &hint); util::json::Object makeRouteLeg(guidance::RouteLeg &&leg, util::json::Array &&steps); diff --git a/include/engine/guidance/assemble_steps.hpp b/include/engine/guidance/assemble_steps.hpp index baa42270655..6beeb69daa4 100644 --- a/include/engine/guidance/assemble_steps.hpp +++ b/include/engine/guidance/assemble_steps.hpp @@ -35,12 +35,12 @@ inline StepManeuver stepManeuverFromGeometry(const extractor::TurnInstruction in const auto turn_coordinate = leg_geometry.locations[turn_index]; const auto post_turn_coordinate = leg_geometry.locations[turn_index + 1]; - const double pre_turn_heading = + const double pre_turn_bearing = util::coordinate_calculation::bearing(pre_turn_coordinate, turn_coordinate); - const double post_turn_heading = + const double post_turn_bearing = util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate); - return StepManeuver{turn_coordinate, pre_turn_heading, post_turn_heading, instruction}; + return StepManeuver{turn_coordinate, pre_turn_bearing, post_turn_bearing, instruction}; } } diff --git a/include/engine/guidance/route_step.hpp b/include/engine/guidance/route_step.hpp index b514c8a47ee..ac5a65d0b9d 100644 --- a/include/engine/guidance/route_step.hpp +++ b/include/engine/guidance/route_step.hpp @@ -22,7 +22,7 @@ namespace guidance struct RouteStep { unsigned name_id; - std::string way_name; + std::string name; double duration; double distance; extractor::TravelMode mode; diff --git a/include/engine/guidance/step_maneuver.hpp b/include/engine/guidance/step_maneuver.hpp index a441f80e79e..6f9c94fd11a 100644 --- a/include/engine/guidance/step_maneuver.hpp +++ b/include/engine/guidance/step_maneuver.hpp @@ -14,8 +14,8 @@ namespace guidance struct StepManeuver { util::FixedPointCoordinate location; - double heading_before; - double heading_after; + double bearing_before; + double bearing_after; extractor::TurnInstruction instruction; }; diff --git a/src/engine/api/josn_factory.cpp b/src/engine/api/josn_factory.cpp index 5b271b3f95f..d5c69b5a9e8 100644 --- a/src/engine/api/josn_factory.cpp +++ b/src/engine/api/josn_factory.cpp @@ -101,14 +101,6 @@ util::json::Array coordinateToLonLat(const FixedPointCoordinate &coordinate) return array; } -util::json::Array coordinateToLatLon(const FixedPointCoordinate &coordinate) -{ - util::json::Array array; - array.values.push_back(coordinate.lat / COORDINATE_PRECISION); - array.values.push_back(coordinate.lon / COORDINATE_PRECISION); - return array; -} - // FIXME this actually needs to be configurable from the profiles std::string modeToString(const extractor::TravelMode mode) { @@ -134,9 +126,9 @@ util::json::Object makeStepManeuver(const guidance::StepManeuver &maneuver) { util::json::Object step_maneuver; step_maneuver.values["type"] = detail::instructionToString(maneuver.instruction); - step_maneuver.values["location"] = detail::coordinateToLatLon(maneuver.location); - step_maneuver.values["heading_before"] = maneuver.heading_before; - step_maneuver.values["heading_after"] = maneuver.heading_after; + step_maneuver.values["location"] = detail::coordinateToLonLat(maneuver.location); + step_maneuver.values["bearing_before"] = maneuver.bearing_before; + step_maneuver.values["bearing_after"] = maneuver.bearing_after; return step_maneuver; } @@ -146,7 +138,7 @@ util::json::Object makeRouteStep(guidance::RouteStep &&step, util::json::Object route_step; route_step.values["distance"] = step.distance; route_step.values["duration"] = step.duration; - route_step.values["way_name"] = std::move(step.way_name); + route_step.values["name"] = std::move(step.name); route_step.values["mode"] = detail::modeToString(step.mode); route_step.values["maneuver"] = makeStepManeuver(step.maneuver); if (geometry) @@ -172,11 +164,11 @@ util::json::Object makeRoute(const guidance::Route &route, } util::json::Object -makeWaypoint(const FixedPointCoordinate location, std::string &&way_name, const Hint &hint) +makeWaypoint(const FixedPointCoordinate location, std::string &&name, const Hint &hint) { util::json::Object waypoint; - waypoint.values["location"] = detail::coordinateToLatLon(location); - waypoint.values["way_name"] = std::move(way_name); + waypoint.values["location"] = detail::coordinateToLonLat(location); + waypoint.values["name"] = std::move(name); waypoint.values["hint"] = hint.ToBase64(); return waypoint; }