2016-01-28 10:28:44 -05:00
|
|
|
#ifndef ENGINE_RESPONSE_OBJECTS_HPP_
|
|
|
|
#define ENGINE_RESPONSE_OBJECTS_HPP_
|
|
|
|
|
2016-03-01 16:30:31 -05:00
|
|
|
#include "extractor/guidance/turn_instruction.hpp"
|
2016-01-28 10:28:44 -05:00
|
|
|
#include "extractor/travel_mode.hpp"
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "engine/guidance/leg_geometry.hpp"
|
|
|
|
#include "engine/guidance/route.hpp"
|
|
|
|
#include "engine/guidance/route_leg.hpp"
|
2016-03-01 08:47:47 -05:00
|
|
|
#include "engine/guidance/route_step.hpp"
|
|
|
|
#include "engine/guidance/step_maneuver.hpp"
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "engine/polyline_compressor.hpp"
|
2016-01-28 10:28:44 -05:00
|
|
|
#include "util/coordinate.hpp"
|
|
|
|
#include "util/json_container.hpp"
|
|
|
|
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
|
|
|
|
#include <algorithm>
|
2016-04-12 09:00:08 -04:00
|
|
|
#include <iterator>
|
|
|
|
#include <string>
|
2016-01-28 10:28:44 -05:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
|
|
|
|
struct Hint;
|
|
|
|
|
|
|
|
namespace api
|
|
|
|
{
|
|
|
|
namespace json
|
|
|
|
{
|
|
|
|
namespace detail
|
|
|
|
{
|
|
|
|
|
2016-05-19 17:26:07 -04:00
|
|
|
std::string instructionTypeToString(extractor::guidance::TurnType::Enum type);
|
|
|
|
std::string instructionModifierToString(extractor::guidance::DirectionModifier::Enum modifier);
|
2016-01-28 10:28:44 -05:00
|
|
|
|
2016-03-01 08:07:55 -05:00
|
|
|
util::json::Array coordinateToLonLat(const util::Coordinate coordinate);
|
2016-01-28 10:28:44 -05:00
|
|
|
|
|
|
|
std::string modeToString(const extractor::TravelMode mode);
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
|
|
template <typename ForwardIter> util::json::String makePolyline(ForwardIter begin, ForwardIter end)
|
|
|
|
{
|
2016-03-01 08:10:14 -05:00
|
|
|
return {encodePolyline(begin, end)};
|
2016-01-28 10:28:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename ForwardIter>
|
2016-04-20 14:49:54 -04:00
|
|
|
util::json::Object makeGeoJSONGeometry(ForwardIter begin, ForwardIter end)
|
2016-01-28 10:28:44 -05:00
|
|
|
{
|
2016-04-20 14:51:45 -04:00
|
|
|
auto num_coordinates = std::distance(begin, end);
|
|
|
|
BOOST_ASSERT(num_coordinates != 0);
|
2016-01-28 10:28:44 -05:00
|
|
|
util::json::Object geojson;
|
2016-04-20 14:51:45 -04:00
|
|
|
if (num_coordinates > 1)
|
2016-04-20 14:49:54 -04:00
|
|
|
{
|
|
|
|
geojson.values["type"] = "LineString";
|
|
|
|
util::json::Array coordinates;
|
2016-06-08 05:28:32 -04:00
|
|
|
coordinates.values.reserve(num_coordinates);
|
2016-05-27 15:05:04 -04:00
|
|
|
std::transform(
|
|
|
|
begin, end, std::back_inserter(coordinates.values), &detail::coordinateToLonLat);
|
2016-04-20 14:49:54 -04:00
|
|
|
geojson.values["coordinates"] = std::move(coordinates);
|
|
|
|
}
|
2016-04-20 14:51:45 -04:00
|
|
|
else if (num_coordinates > 0)
|
2016-04-20 14:49:54 -04:00
|
|
|
{
|
|
|
|
geojson.values["type"] = "Point";
|
|
|
|
util::json::Array coordinates;
|
|
|
|
coordinates.values.push_back(detail::coordinateToLonLat(*begin));
|
|
|
|
geojson.values["coordinates"] = std::move(coordinates);
|
|
|
|
}
|
2016-01-28 10:28:44 -05:00
|
|
|
return geojson;
|
|
|
|
}
|
|
|
|
|
|
|
|
util::json::Object makeStepManeuver(const guidance::StepManeuver &maneuver);
|
|
|
|
|
2016-10-28 17:45:05 -04:00
|
|
|
util::json::Object makeRouteStep(guidance::RouteStep step, util::json::Value geometry);
|
2016-01-28 10:28:44 -05:00
|
|
|
|
|
|
|
util::json::Object makeRoute(const guidance::Route &route,
|
2016-03-01 08:47:47 -05:00
|
|
|
util::json::Array legs,
|
2016-01-28 10:28:44 -05:00
|
|
|
boost::optional<util::json::Value> geometry);
|
|
|
|
|
|
|
|
util::json::Object
|
2016-03-01 08:47:47 -05:00
|
|
|
makeWaypoint(const util::Coordinate location, std::string name, const Hint &hint);
|
2016-01-28 10:28:44 -05:00
|
|
|
|
2016-03-01 08:47:47 -05:00
|
|
|
util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps);
|
2016-01-28 10:28:44 -05:00
|
|
|
|
2016-03-01 08:47:47 -05:00
|
|
|
util::json::Array makeRouteLegs(std::vector<guidance::RouteLeg> legs,
|
2016-05-26 18:39:46 -04:00
|
|
|
std::vector<util::json::Value> step_geometries,
|
|
|
|
std::vector<util::json::Object> annotations);
|
2016-01-28 10:28:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace engine
|
|
|
|
} // namespace osrm
|
|
|
|
|
|
|
|
#endif // ENGINE_GUIDANCE_API_RESPONSE_GENERATOR_HPP_
|