2015-01-27 11:44:46 -05:00
|
|
|
#ifndef HELLO_WORLD_HPP
|
|
|
|
#define HELLO_WORLD_HPP
|
2011-01-09 16:42:27 -05:00
|
|
|
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "engine/plugins/plugin_base.hpp"
|
2014-11-28 09:13:29 -05:00
|
|
|
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "osrm/json_container.hpp"
|
2014-11-24 11:57:01 -05:00
|
|
|
|
2013-11-14 17:16:26 -05:00
|
|
|
#include <string>
|
2013-06-26 19:48:02 -04:00
|
|
|
|
2014-10-13 11:29:53 -04:00
|
|
|
class HelloWorldPlugin final : public BasePlugin
|
2014-05-02 12:06:31 -04:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::string temp_string;
|
|
|
|
|
|
|
|
public:
|
|
|
|
HelloWorldPlugin() : descriptor_string("hello") {}
|
|
|
|
virtual ~HelloWorldPlugin() {}
|
2015-01-28 04:10:28 -05:00
|
|
|
const std::string GetDescriptor() const override final { return descriptor_string; }
|
2014-05-02 12:06:31 -04:00
|
|
|
|
2015-12-17 10:45:15 -05:00
|
|
|
Status HandleRequest(const RouteParameters &routeParameters,
|
2016-01-05 06:04:04 -05:00
|
|
|
osrm::json::Object &json_result) override final
|
2014-05-02 12:06:31 -04:00
|
|
|
{
|
2014-05-16 10:09:40 -04:00
|
|
|
std::string temp_string;
|
|
|
|
json_result.values["title"] = "Hello World";
|
|
|
|
|
2015-09-08 21:31:03 -04:00
|
|
|
temp_string = std::to_string(routeParameters.zoom_level);
|
2014-05-16 10:09:40 -04:00
|
|
|
json_result.values["zoom_level"] = temp_string;
|
|
|
|
|
2015-09-08 21:31:03 -04:00
|
|
|
temp_string = std::to_string(routeParameters.check_sum);
|
2015-01-05 06:57:34 -05:00
|
|
|
json_result.values["check_sum"] = temp_string;
|
2014-05-16 10:09:40 -04:00
|
|
|
json_result.values["instructions"] = (routeParameters.print_instructions ? "yes" : "no");
|
|
|
|
json_result.values["geometry"] = (routeParameters.geometry ? "yes" : "no");
|
|
|
|
json_result.values["compression"] = (routeParameters.compression ? "yes" : "no");
|
2014-08-18 04:19:33 -04:00
|
|
|
json_result.values["output_format"] =
|
|
|
|
(!routeParameters.output_format.empty() ? "yes" : "no");
|
2014-05-16 10:09:40 -04:00
|
|
|
|
2014-08-18 04:19:33 -04:00
|
|
|
json_result.values["jsonp_parameter"] =
|
|
|
|
(!routeParameters.jsonp_parameter.empty() ? "yes" : "no");
|
2014-05-16 10:09:40 -04:00
|
|
|
json_result.values["language"] = (!routeParameters.language.empty() ? "yes" : "no");
|
|
|
|
|
2015-09-08 21:31:03 -04:00
|
|
|
temp_string = std::to_string(routeParameters.coordinates.size());
|
2014-05-16 10:09:40 -04:00
|
|
|
json_result.values["location_count"] = temp_string;
|
|
|
|
|
2015-02-18 04:46:40 -05:00
|
|
|
osrm::json::Array json_locations;
|
2014-05-02 12:06:31 -04:00
|
|
|
unsigned counter = 0;
|
|
|
|
for (const FixedPointCoordinate &coordinate : routeParameters.coordinates)
|
|
|
|
{
|
2015-02-18 04:46:40 -05:00
|
|
|
osrm::json::Object json_location;
|
|
|
|
osrm::json::Array json_coordinates;
|
2014-05-16 10:09:40 -04:00
|
|
|
|
2015-01-27 11:44:46 -05:00
|
|
|
json_coordinates.values.push_back(
|
|
|
|
static_cast<double>(coordinate.lat / COORDINATE_PRECISION));
|
|
|
|
json_coordinates.values.push_back(
|
|
|
|
static_cast<double>(coordinate.lon / COORDINATE_PRECISION));
|
2015-09-08 21:31:03 -04:00
|
|
|
json_location.values[std::to_string(counter)] = json_coordinates;
|
2014-05-16 10:09:40 -04:00
|
|
|
json_locations.values.push_back(json_location);
|
2014-05-02 12:06:31 -04:00
|
|
|
++counter;
|
2012-09-12 09:01:37 -04:00
|
|
|
}
|
2014-05-16 10:09:40 -04:00
|
|
|
json_result.values["locations"] = json_locations;
|
2015-01-05 06:57:34 -05:00
|
|
|
json_result.values["hint_count"] = routeParameters.hints.size();
|
|
|
|
|
2015-02-18 04:46:40 -05:00
|
|
|
osrm::json::Array json_hints;
|
2015-01-05 06:57:34 -05:00
|
|
|
counter = 0;
|
|
|
|
for (const std::string ¤t_hint : routeParameters.hints)
|
|
|
|
{
|
|
|
|
json_hints.values.push_back(current_hint);
|
|
|
|
++counter;
|
|
|
|
}
|
|
|
|
json_result.values["hints"] = json_hints;
|
2015-12-17 10:45:15 -05:00
|
|
|
return Status::Ok;
|
2014-05-02 12:06:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2013-08-13 12:09:20 -04:00
|
|
|
std::string descriptor_string;
|
2011-01-09 16:42:27 -05:00
|
|
|
};
|
|
|
|
|
2015-01-27 11:44:46 -05:00
|
|
|
#endif // HELLO_WORLD_HPP
|