Passed ResultT down to engine plugins, so now they can form replies in different formats.
This commit is contained in:
		
							parent
							
								
									f6f86b2a52
								
							
						
					
					
						commit
						75aadb0f3f
					
				
							
								
								
									
										21
									
								
								include/engine/api/base_result.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								include/engine/api/base_result.hpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | |||||||
|  | #ifndef ENGINE_API_BASE_RESULT_HPP | ||||||
|  | #define ENGINE_API_BASE_RESULT_HPP | ||||||
|  | 
 | ||||||
|  | #include <mapbox/variant.hpp> | ||||||
|  | 
 | ||||||
|  | #include <string> | ||||||
|  | 
 | ||||||
|  | #include "util/json_container.hpp" | ||||||
|  | 
 | ||||||
|  | namespace osrm | ||||||
|  | { | ||||||
|  | namespace engine | ||||||
|  | { | ||||||
|  | namespace api | ||||||
|  | { | ||||||
|  |     using ResultT = mapbox::util::variant<util::json::Object, std::string>; | ||||||
|  | } // ns api
 | ||||||
|  | } // ns engine
 | ||||||
|  | } // ns osrm
 | ||||||
|  | 
 | ||||||
|  | #endif | ||||||
| @ -33,16 +33,17 @@ class EngineInterface | |||||||
|   public: |   public: | ||||||
|     virtual ~EngineInterface() = default; |     virtual ~EngineInterface() = default; | ||||||
|     virtual Status Route(const api::RouteParameters ¶meters, |     virtual Status Route(const api::RouteParameters ¶meters, | ||||||
|                          util::json::Object &result) const = 0; |                          api::ResultT &result) const = 0; | ||||||
|     virtual Status Table(const api::TableParameters ¶meters, |     virtual Status Table(const api::TableParameters ¶meters, | ||||||
|                          util::json::Object &result) const = 0; |                          api::ResultT &result) const = 0; | ||||||
|     virtual Status Nearest(const api::NearestParameters ¶meters, |     virtual Status Nearest(const api::NearestParameters ¶meters, | ||||||
|                            util::json::Object &result) const = 0; |                            api::ResultT &result) const = 0; | ||||||
|     virtual Status Trip(const api::TripParameters ¶meters, |     virtual Status Trip(const api::TripParameters ¶meters, | ||||||
|                         util::json::Object &result) const = 0; |                         api::ResultT &result) const = 0; | ||||||
|     virtual Status Match(const api::MatchParameters ¶meters, |     virtual Status Match(const api::MatchParameters ¶meters, | ||||||
|                          util::json::Object &result) const = 0; |                          api::ResultT &result) const = 0; | ||||||
|     virtual Status Tile(const api::TileParameters ¶meters, std::string &result) const = 0; |     virtual Status Tile(const api::TileParameters ¶meters, | ||||||
|  |                         api::ResultT &result) const = 0; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template <typename Algorithm> class Engine final : public EngineInterface | template <typename Algorithm> class Engine final : public EngineInterface | ||||||
| @ -90,35 +91,37 @@ template <typename Algorithm> class Engine final : public EngineInterface | |||||||
|     virtual ~Engine() = default; |     virtual ~Engine() = default; | ||||||
| 
 | 
 | ||||||
|     Status Route(const api::RouteParameters ¶ms, |     Status Route(const api::RouteParameters ¶ms, | ||||||
|                  util::json::Object &result) const override final |                  api::ResultT &result) const override final | ||||||
|     { |     { | ||||||
|         return route_plugin.HandleRequest(GetAlgorithms(params), params, result); |         return route_plugin.HandleRequest(GetAlgorithms(params), params, result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Status Table(const api::TableParameters ¶ms, |     Status Table(const api::TableParameters ¶ms, | ||||||
|                  util::json::Object &result) const override final |                  api::ResultT &result) const override final | ||||||
|     { |     { | ||||||
|         return table_plugin.HandleRequest(GetAlgorithms(params), params, result); |         return table_plugin.HandleRequest(GetAlgorithms(params), params, result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Status Nearest(const api::NearestParameters ¶ms, |     Status Nearest(const api::NearestParameters ¶ms, | ||||||
|                    util::json::Object &result) const override final |                    api::ResultT &result) const override final | ||||||
|     { |     { | ||||||
|         return nearest_plugin.HandleRequest(GetAlgorithms(params), params, result); |         return nearest_plugin.HandleRequest(GetAlgorithms(params), params, result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Status Trip(const api::TripParameters ¶ms, util::json::Object &result) const override final |     Status Trip(const api::TripParameters ¶ms, | ||||||
|  |                 api::ResultT &result) const override final | ||||||
|     { |     { | ||||||
|         return trip_plugin.HandleRequest(GetAlgorithms(params), params, result); |         return trip_plugin.HandleRequest(GetAlgorithms(params), params, result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Status Match(const api::MatchParameters ¶ms, |     Status Match(const api::MatchParameters ¶ms, | ||||||
|                  util::json::Object &result) const override final |                  api::ResultT &result) const override final | ||||||
|     { |     { | ||||||
|         return match_plugin.HandleRequest(GetAlgorithms(params), params, result); |         return match_plugin.HandleRequest(GetAlgorithms(params), params, result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Status Tile(const api::TileParameters ¶ms, std::string &result) const override final |     Status Tile(const api::TileParameters ¶ms, | ||||||
|  |                 api::ResultT &result) const override final | ||||||
|     { |     { | ||||||
|         return tile_plugin.HandleRequest(GetAlgorithms(params), params, result); |         return tile_plugin.HandleRequest(GetAlgorithms(params), params, result); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -32,7 +32,7 @@ class MatchPlugin : public BasePlugin | |||||||
| 
 | 
 | ||||||
|     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, |     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                          const api::MatchParameters ¶meters, |                          const api::MatchParameters ¶meters, | ||||||
|                          util::json::Object &json_result) const; |                          osrm::engine::api::ResultT &json_result) const; | ||||||
| 
 | 
 | ||||||
|   private: |   private: | ||||||
|     const int max_locations_map_matching; |     const int max_locations_map_matching; | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ class NearestPlugin final : public BasePlugin | |||||||
| 
 | 
 | ||||||
|     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, |     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                          const api::NearestParameters ¶ms, |                          const api::NearestParameters ¶ms, | ||||||
|                          util::json::Object &result) const; |                          osrm::engine::api::ResultT &result) const; | ||||||
| 
 | 
 | ||||||
|   private: |   private: | ||||||
|     const int max_results; |     const int max_results; | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ | |||||||
| #define BASE_PLUGIN_HPP | #define BASE_PLUGIN_HPP | ||||||
| 
 | 
 | ||||||
| #include "engine/api/base_parameters.hpp" | #include "engine/api/base_parameters.hpp" | ||||||
|  | #include "engine/api/base_result.hpp" | ||||||
| #include "engine/datafacade/datafacade_base.hpp" | #include "engine/datafacade/datafacade_base.hpp" | ||||||
| #include "engine/phantom_node.hpp" | #include "engine/phantom_node.hpp" | ||||||
| #include "engine/routing_algorithms.hpp" | #include "engine/routing_algorithms.hpp" | ||||||
| @ -39,7 +40,7 @@ class BasePlugin | |||||||
| 
 | 
 | ||||||
|     bool CheckAlgorithms(const api::BaseParameters ¶ms, |     bool CheckAlgorithms(const api::BaseParameters ¶ms, | ||||||
|                          const RoutingAlgorithmsInterface &algorithms, |                          const RoutingAlgorithmsInterface &algorithms, | ||||||
|                          util::json::Object &result) const |                          osrm::engine::api::ResultT &result) const | ||||||
|     { |     { | ||||||
|         if (algorithms.IsValid()) |         if (algorithms.IsValid()) | ||||||
|         { |         { | ||||||
| @ -64,8 +65,10 @@ class BasePlugin | |||||||
| 
 | 
 | ||||||
|     Status Error(const std::string &code, |     Status Error(const std::string &code, | ||||||
|                  const std::string &message, |                  const std::string &message, | ||||||
|                  util::json::Object &json_result) const |                  osrm::engine::api::ResultT &result) const | ||||||
|     { |     { | ||||||
|  |         result = util::json::Object(); | ||||||
|  |         auto& json_result = result.get<util::json::Object>(); | ||||||
|         json_result.values["code"] = code; |         json_result.values["code"] = code; | ||||||
|         json_result.values["message"] = message; |         json_result.values["message"] = message; | ||||||
|         return Status::Error; |         return Status::Error; | ||||||
|  | |||||||
| @ -22,7 +22,7 @@ class TablePlugin final : public BasePlugin | |||||||
| 
 | 
 | ||||||
|     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, |     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                          const api::TableParameters ¶ms, |                          const api::TableParameters ¶ms, | ||||||
|                          util::json::Object &result) const; |                          osrm::engine::api::ResultT &result) const; | ||||||
| 
 | 
 | ||||||
|   private: |   private: | ||||||
|     const int max_locations_distance_table; |     const int max_locations_distance_table; | ||||||
|  | |||||||
| @ -28,7 +28,7 @@ class TilePlugin final : public BasePlugin | |||||||
|   public: |   public: | ||||||
|     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, |     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                          const api::TileParameters ¶meters, |                          const api::TileParameters ¶meters, | ||||||
|                          std::string &pbf_buffer) const; |                          osrm::engine::api::ResultT &pbf_buffer) const; | ||||||
| }; | }; | ||||||
| } | } | ||||||
| } | } | ||||||
|  | |||||||
| @ -40,7 +40,7 @@ class TripPlugin final : public BasePlugin | |||||||
| 
 | 
 | ||||||
|     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, |     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                          const api::TripParameters ¶meters, |                          const api::TripParameters ¶meters, | ||||||
|                          util::json::Object &json_result) const; |                          osrm::engine::api::ResultT &json_result) const; | ||||||
| }; | }; | ||||||
| } | } | ||||||
| } | } | ||||||
|  | |||||||
| @ -33,7 +33,7 @@ class ViaRoutePlugin final : public BasePlugin | |||||||
| 
 | 
 | ||||||
|     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, |     Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                          const api::RouteParameters &route_parameters, |                          const api::RouteParameters &route_parameters, | ||||||
|                          util::json::Object &json_result) const; |                          osrm::engine::api::ResultT &json_result) const; | ||||||
| }; | }; | ||||||
| } | } | ||||||
| } | } | ||||||
|  | |||||||
| @ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| 
 | 
 | ||||||
| #include "osrm/osrm_fwd.hpp" | #include "osrm/osrm_fwd.hpp" | ||||||
| #include "osrm/status.hpp" | #include "osrm/status.hpp" | ||||||
|  | #include "engine/api/base_result.hpp" | ||||||
| 
 | 
 | ||||||
| #include <memory> | #include <memory> | ||||||
| #include <string> | #include <string> | ||||||
| @ -83,7 +84,7 @@ class OSRM final | |||||||
|      * \return Status indicating success for the query or failure |      * \return Status indicating success for the query or failure | ||||||
|      * \see Status, RouteParameters and json::Object |      * \see Status, RouteParameters and json::Object | ||||||
|      */ |      */ | ||||||
|     Status Route(const RouteParameters ¶meters, json::Object &result) const; |     Status Route(const RouteParameters ¶meters, osrm::engine::api::ResultT &result) const; | ||||||
| 
 | 
 | ||||||
|     /**
 |     /**
 | ||||||
|      * Distance tables for coordinates. |      * Distance tables for coordinates. | ||||||
| @ -92,7 +93,7 @@ class OSRM final | |||||||
|      * \return Status indicating success for the query or failure |      * \return Status indicating success for the query or failure | ||||||
|      * \see Status, TableParameters and json::Object |      * \see Status, TableParameters and json::Object | ||||||
|      */ |      */ | ||||||
|     Status Table(const TableParameters ¶meters, json::Object &result) const; |     Status Table(const TableParameters ¶meters, osrm::engine::api::ResultT &result) const; | ||||||
| 
 | 
 | ||||||
|     /**
 |     /**
 | ||||||
|      * Nearest street segment for coordinate. |      * Nearest street segment for coordinate. | ||||||
| @ -101,7 +102,7 @@ class OSRM final | |||||||
|      * \return Status indicating success for the query or failure |      * \return Status indicating success for the query or failure | ||||||
|      * \see Status, NearestParameters and json::Object |      * \see Status, NearestParameters and json::Object | ||||||
|      */ |      */ | ||||||
|     Status Nearest(const NearestParameters ¶meters, json::Object &result) const; |     Status Nearest(const NearestParameters ¶meters, osrm::engine::api::ResultT &result) const; | ||||||
| 
 | 
 | ||||||
|     /**
 |     /**
 | ||||||
|      * Trip: shortest round trip between coordinates. |      * Trip: shortest round trip between coordinates. | ||||||
| @ -110,7 +111,7 @@ class OSRM final | |||||||
|      * \return Status indicating success for the query or failure |      * \return Status indicating success for the query or failure | ||||||
|      * \see Status, TripParameters and json::Object |      * \see Status, TripParameters and json::Object | ||||||
|      */ |      */ | ||||||
|     Status Trip(const TripParameters ¶meters, json::Object &result) const; |     Status Trip(const TripParameters ¶meters, osrm::engine::api::ResultT &result) const; | ||||||
| 
 | 
 | ||||||
|     /**
 |     /**
 | ||||||
|      * Match: snaps noisy coordinate traces to the road network |      * Match: snaps noisy coordinate traces to the road network | ||||||
| @ -119,7 +120,7 @@ class OSRM final | |||||||
|      * \return Status indicating success for the query or failure |      * \return Status indicating success for the query or failure | ||||||
|      * \see Status, MatchParameters and json::Object |      * \see Status, MatchParameters and json::Object | ||||||
|      */ |      */ | ||||||
|     Status Match(const MatchParameters ¶meters, json::Object &result) const; |     Status Match(const MatchParameters ¶meters, osrm::engine::api::ResultT &result) const; | ||||||
| 
 | 
 | ||||||
|     /**
 |     /**
 | ||||||
|      * Tile: vector tiles with internal graph representation |      * Tile: vector tiles with internal graph representation | ||||||
| @ -128,7 +129,7 @@ class OSRM final | |||||||
|      * \return Status indicating success for the query or failure |      * \return Status indicating success for the query or failure | ||||||
|      * \see Status, TileParameters and json::Object |      * \see Status, TileParameters and json::Object | ||||||
|      */ |      */ | ||||||
|     Status Tile(const TileParameters ¶meters, std::string &result) const; |     Status Tile(const TileParameters ¶meters, osrm::engine::api::ResultT &result) const; | ||||||
| 
 | 
 | ||||||
|   private: |   private: | ||||||
|     std::unique_ptr<engine::EngineInterface> engine_; |     std::unique_ptr<engine::EngineInterface> engine_; | ||||||
|  | |||||||
| @ -20,13 +20,11 @@ namespace service | |||||||
| class BaseService | class BaseService | ||||||
| { | { | ||||||
|   public: |   public: | ||||||
|     using ResultT = mapbox::util::variant<util::json::Object, std::string>; |  | ||||||
| 
 |  | ||||||
|     BaseService(OSRM &routing_machine) : routing_machine(routing_machine) {} |     BaseService(OSRM &routing_machine) : routing_machine(routing_machine) {} | ||||||
|     virtual ~BaseService() = default; |     virtual ~BaseService() = default; | ||||||
| 
 | 
 | ||||||
|     virtual engine::Status |     virtual engine::Status | ||||||
|     RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) = 0; |     RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) = 0; | ||||||
| 
 | 
 | ||||||
|     virtual unsigned GetVersion() = 0; |     virtual unsigned GetVersion() = 0; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ class MatchService final : public BaseService | |||||||
|     MatchService(OSRM &routing_machine) : BaseService(routing_machine) {} |     MatchService(OSRM &routing_machine) : BaseService(routing_machine) {} | ||||||
| 
 | 
 | ||||||
|     engine::Status |     engine::Status | ||||||
|     RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; |     RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) final override; | ||||||
| 
 | 
 | ||||||
|     unsigned GetVersion() final override { return 1; } |     unsigned GetVersion() final override { return 1; } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ class NearestService final : public BaseService | |||||||
|     NearestService(OSRM &routing_machine) : BaseService(routing_machine) {} |     NearestService(OSRM &routing_machine) : BaseService(routing_machine) {} | ||||||
| 
 | 
 | ||||||
|     engine::Status |     engine::Status | ||||||
|     RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; |     RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) final override; | ||||||
| 
 | 
 | ||||||
|     unsigned GetVersion() final override { return 1; } |     unsigned GetVersion() final override { return 1; } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ class RouteService final : public BaseService | |||||||
|     RouteService(OSRM &routing_machine) : BaseService(routing_machine) {} |     RouteService(OSRM &routing_machine) : BaseService(routing_machine) {} | ||||||
| 
 | 
 | ||||||
|     engine::Status |     engine::Status | ||||||
|     RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; |     RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) final override; | ||||||
| 
 | 
 | ||||||
|     unsigned GetVersion() final override { return 1; } |     unsigned GetVersion() final override { return 1; } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ class TableService final : public BaseService | |||||||
|     TableService(OSRM &routing_machine) : BaseService(routing_machine) {} |     TableService(OSRM &routing_machine) : BaseService(routing_machine) {} | ||||||
| 
 | 
 | ||||||
|     engine::Status |     engine::Status | ||||||
|     RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; |     RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) final override; | ||||||
| 
 | 
 | ||||||
|     unsigned GetVersion() final override { return 1; } |     unsigned GetVersion() final override { return 1; } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ class TileService final : public BaseService | |||||||
|     TileService(OSRM &routing_machine) : BaseService(routing_machine) {} |     TileService(OSRM &routing_machine) : BaseService(routing_machine) {} | ||||||
| 
 | 
 | ||||||
|     engine::Status |     engine::Status | ||||||
|     RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; |     RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) final override; | ||||||
| 
 | 
 | ||||||
|     unsigned GetVersion() final override { return 1; } |     unsigned GetVersion() final override { return 1; } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ class TripService final : public BaseService | |||||||
|     TripService(OSRM &routing_machine) : BaseService(routing_machine) {} |     TripService(OSRM &routing_machine) : BaseService(routing_machine) {} | ||||||
| 
 | 
 | ||||||
|     engine::Status |     engine::Status | ||||||
|     RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override; |     RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) final override; | ||||||
| 
 | 
 | ||||||
|     unsigned GetVersion() final override { return 1; } |     unsigned GetVersion() final override { return 1; } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -4,6 +4,7 @@ | |||||||
| #include "server/service/base_service.hpp" | #include "server/service/base_service.hpp" | ||||||
| 
 | 
 | ||||||
| #include "osrm/osrm.hpp" | #include "osrm/osrm.hpp" | ||||||
|  | #include "engine/api/base_api.hpp" | ||||||
| 
 | 
 | ||||||
| #include <unordered_map> | #include <unordered_map> | ||||||
| 
 | 
 | ||||||
| @ -28,14 +29,14 @@ class ServiceHandlerInterface | |||||||
|   public: |   public: | ||||||
|     virtual ~ServiceHandlerInterface() {} |     virtual ~ServiceHandlerInterface() {} | ||||||
|     virtual engine::Status RunQuery(api::ParsedURL parsed_url, |     virtual engine::Status RunQuery(api::ParsedURL parsed_url, | ||||||
|                                     service::BaseService::ResultT &result) = 0; |                                     osrm::engine::api::ResultT &result) = 0; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class ServiceHandler final : public ServiceHandlerInterface | class ServiceHandler final : public ServiceHandlerInterface | ||||||
| { | { | ||||||
|   public: |   public: | ||||||
|     ServiceHandler(osrm::EngineConfig &config); |     ServiceHandler(osrm::EngineConfig &config); | ||||||
|     using ResultT = service::BaseService::ResultT; |     using ResultT = osrm::engine::api::ResultT; | ||||||
| 
 | 
 | ||||||
|     virtual engine::Status RunQuery(api::ParsedURL parsed_url, ResultT &result) override; |     virtual engine::Status RunQuery(api::ParsedURL parsed_url, ResultT &result) override; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -112,16 +112,17 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates, | |||||||
| 
 | 
 | ||||||
| Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                                   const api::MatchParameters ¶meters, |                                   const api::MatchParameters ¶meters, | ||||||
|                                   util::json::Object &json_result) const |                                   osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|  |     auto& json_result = result.get<util::json::Object>(); | ||||||
|     if (!algorithms.HasMapMatching()) |     if (!algorithms.HasMapMatching()) | ||||||
|     { |     { | ||||||
|         return Error("NotImplemented", |         return Error("NotImplemented", | ||||||
|                      "Map matching is not implemented for the chosen search algorithm.", |                      "Map matching is not implemented for the chosen search algorithm.", | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!CheckAlgorithms(parameters, algorithms, json_result)) |     if (!CheckAlgorithms(parameters, algorithms, result)) | ||||||
|         return Status::Error; |         return Status::Error; | ||||||
| 
 | 
 | ||||||
|     const auto &facade = algorithms.GetFacade(); |     const auto &facade = algorithms.GetFacade(); | ||||||
| @ -132,12 +133,12 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
|     if (max_locations_map_matching > 0 && |     if (max_locations_map_matching > 0 && | ||||||
|         static_cast<int>(parameters.coordinates.size()) > max_locations_map_matching) |         static_cast<int>(parameters.coordinates.size()) > max_locations_map_matching) | ||||||
|     { |     { | ||||||
|         return Error("TooBig", "Too many trace coordinates", json_result); |         return Error("TooBig", "Too many trace coordinates", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!CheckAllCoordinates(parameters.coordinates)) |     if (!CheckAllCoordinates(parameters.coordinates)) | ||||||
|     { |     { | ||||||
|         return Error("InvalidValue", "Invalid coordinate value.", json_result); |         return Error("InvalidValue", "Invalid coordinate value.", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (max_radius_map_matching > 0 && std::any_of(parameters.radiuses.begin(), |     if (max_radius_map_matching > 0 && std::any_of(parameters.radiuses.begin(), | ||||||
| @ -148,7 +149,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
|                                                        return *radius > max_radius_map_matching; |                                                        return *radius > max_radius_map_matching; | ||||||
|                                                    })) |                                                    })) | ||||||
|     { |     { | ||||||
|         return Error("TooBig", "Radius search size is too large for map matching.", json_result); |         return Error("TooBig", "Radius search size is too large for map matching.", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Check for same or increasing timestamps. Impl. note: Incontrast to `sort(first,
 |     // Check for same or increasing timestamps. Impl. note: Incontrast to `sort(first,
 | ||||||
| @ -159,7 +160,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
|     if (!time_increases_monotonically) |     if (!time_increases_monotonically) | ||||||
|     { |     { | ||||||
|         return Error( |         return Error( | ||||||
|             "InvalidValue", "Timestamps need to be monotonically increasing.", json_result); |             "InvalidValue", "Timestamps need to be monotonically increasing.", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     SubMatchingList sub_matchings; |     SubMatchingList sub_matchings; | ||||||
| @ -182,7 +183,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
|     { |     { | ||||||
|         return Error("InvalidValue", |         return Error("InvalidValue", | ||||||
|                      "First and last coordinates must be specified as waypoints.", |                      "First and last coordinates must be specified as waypoints.", | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // assuming radius is the standard deviation of a normal distribution
 |     // assuming radius is the standard deviation of a normal distribution
 | ||||||
| @ -225,7 +226,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
|     { |     { | ||||||
|         return Error("NoSegment", |         return Error("NoSegment", | ||||||
|                      std::string("Could not find a matching segment for any coordinate."), |                      std::string("Could not find a matching segment for any coordinate."), | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // call the actual map matching
 |     // call the actual map matching
 | ||||||
| @ -238,13 +239,13 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
| 
 | 
 | ||||||
|     if (sub_matchings.size() == 0) |     if (sub_matchings.size() == 0) | ||||||
|     { |     { | ||||||
|         return Error("NoMatch", "Could not match the trace.", json_result); |         return Error("NoMatch", "Could not match the trace.", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // trace was split, we don't support the waypoints parameter across multiple match objects
 |     // trace was split, we don't support the waypoints parameter across multiple match objects
 | ||||||
|     if (sub_matchings.size() > 1 && !parameters.waypoints.empty()) |     if (sub_matchings.size() > 1 && !parameters.waypoints.empty()) | ||||||
|     { |     { | ||||||
|         return Error("NoMatch", "Could not match the trace with the given waypoints.", json_result); |         return Error("NoMatch", "Could not match the trace with the given waypoints.", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Error: Check if user-supplied waypoints can be found in the resulting matches
 |     // Error: Check if user-supplied waypoints can be found in the resulting matches
 | ||||||
| @ -261,7 +262,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
|         if (!tidied_waypoints.empty()) |         if (!tidied_waypoints.empty()) | ||||||
|         { |         { | ||||||
|             return Error( |             return Error( | ||||||
|                 "NoMatch", "Requested waypoint parameter could not be matched.", json_result); |                 "NoMatch", "Requested waypoint parameter could not be matched.", result); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     // we haven't errored yet, only allow leg collapsing if it was originally requested
 |     // we haven't errored yet, only allow leg collapsing if it was originally requested
 | ||||||
|  | |||||||
| @ -21,11 +21,12 @@ NearestPlugin::NearestPlugin(const int max_results_) : max_results{max_results_} | |||||||
| 
 | 
 | ||||||
| Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                                     const api::NearestParameters ¶ms, |                                     const api::NearestParameters ¶ms, | ||||||
|                                     util::json::Object &json_result) const |                                     osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|     BOOST_ASSERT(params.IsValid()); |     BOOST_ASSERT(params.IsValid()); | ||||||
| 
 | 
 | ||||||
|     if (!CheckAlgorithms(params, algorithms, json_result)) |     auto& json_result = result.get<util::json::Object>(); | ||||||
|  |     if (!CheckAlgorithms(params, algorithms, result)) | ||||||
|         return Status::Error; |         return Status::Error; | ||||||
| 
 | 
 | ||||||
|     const auto &facade = algorithms.GetFacade(); |     const auto &facade = algorithms.GetFacade(); | ||||||
| @ -36,22 +37,22 @@ Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms | |||||||
|         return Error("TooBig", |         return Error("TooBig", | ||||||
|                      "Number of results " + std::to_string(params.number_of_results) + |                      "Number of results " + std::to_string(params.number_of_results) + | ||||||
|                          " is higher than current maximum (" + std::to_string(max_results) + ")", |                          " is higher than current maximum (" + std::to_string(max_results) + ")", | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!CheckAllCoordinates(params.coordinates)) |     if (!CheckAllCoordinates(params.coordinates)) | ||||||
|         return Error("InvalidOptions", "Coordinates are invalid", json_result); |         return Error("InvalidOptions", "Coordinates are invalid", result); | ||||||
| 
 | 
 | ||||||
|     if (params.coordinates.size() != 1) |     if (params.coordinates.size() != 1) | ||||||
|     { |     { | ||||||
|         return Error("InvalidOptions", "Only one input coordinate is supported", json_result); |         return Error("InvalidOptions", "Only one input coordinate is supported", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     auto phantom_nodes = GetPhantomNodes(facade, params, params.number_of_results); |     auto phantom_nodes = GetPhantomNodes(facade, params, params.number_of_results); | ||||||
| 
 | 
 | ||||||
|     if (phantom_nodes.front().size() == 0) |     if (phantom_nodes.front().size() == 0) | ||||||
|     { |     { | ||||||
|         return Error("NoSegment", "Could not find a matching segments for coordinate", json_result); |         return Error("NoSegment", "Could not find a matching segments for coordinate", result); | ||||||
|     } |     } | ||||||
|     BOOST_ASSERT(phantom_nodes.front().size() > 0); |     BOOST_ASSERT(phantom_nodes.front().size() > 0); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -31,8 +31,9 @@ TablePlugin::TablePlugin(const int max_locations_distance_table) | |||||||
| 
 | 
 | ||||||
| Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                                   const api::TableParameters ¶ms, |                                   const api::TableParameters ¶ms, | ||||||
|                                   util::json::Object &result) const |                                   osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|  |     auto& json_result = result.get<util::json::Object>(); | ||||||
|     if (!algorithms.HasManyToManySearch()) |     if (!algorithms.HasManyToManySearch()) | ||||||
|     { |     { | ||||||
|         return Error("NotImplemented", |         return Error("NotImplemented", | ||||||
| @ -154,7 +155,7 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     api::TableAPI table_api{facade, params}; |     api::TableAPI table_api{facade, params}; | ||||||
|     table_api.MakeResponse(result_tables_pair, snapped_phantoms, estimated_pairs, result); |     table_api.MakeResponse(result_tables_pair, snapped_phantoms, estimated_pairs, json_result); | ||||||
| 
 | 
 | ||||||
|     return Status::Ok; |     return Status::Ok; | ||||||
| } | } | ||||||
|  | |||||||
| @ -665,10 +665,11 @@ void encodeVectorTile(const DataFacadeBase &facade, | |||||||
| 
 | 
 | ||||||
| Status TilePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | Status TilePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                                  const api::TileParameters ¶meters, |                                  const api::TileParameters ¶meters, | ||||||
|                                  std::string &pbf_buffer) const |                                  osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|     BOOST_ASSERT(parameters.IsValid()); |     BOOST_ASSERT(parameters.IsValid()); | ||||||
| 
 | 
 | ||||||
|  |     auto& pbf_buffer = result.get<std::string>(); | ||||||
|     const auto &facade = algorithms.GetFacade(); |     const auto &facade = algorithms.GetFacade(); | ||||||
|     auto edges = getEdges(facade, parameters.x, parameters.y, parameters.z); |     auto edges = getEdges(facade, parameters.x, parameters.y, parameters.z); | ||||||
|     auto segregated_nodes = getSegregatedNodes(facade, edges); |     auto segregated_nodes = getSegregatedNodes(facade, edges); | ||||||
|  | |||||||
| @ -144,19 +144,20 @@ void ManipulateTableForFSE(const std::size_t source_id, | |||||||
| 
 | 
 | ||||||
| Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                                  const api::TripParameters ¶meters, |                                  const api::TripParameters ¶meters, | ||||||
|                                  util::json::Object &json_result) const |                                  osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|  |     auto& json_result = result.get<util::json::Object>(); | ||||||
|     if (!algorithms.HasShortestPathSearch()) |     if (!algorithms.HasShortestPathSearch()) | ||||||
|     { |     { | ||||||
|         return Error("NotImplemented", |         return Error("NotImplemented", | ||||||
|                      "Shortest path search is not implemented for the chosen search algorithm.", |                      "Shortest path search is not implemented for the chosen search algorithm.", | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
|     if (!algorithms.HasManyToManySearch()) |     if (!algorithms.HasManyToManySearch()) | ||||||
|     { |     { | ||||||
|         return Error("NotImplemented", |         return Error("NotImplemented", | ||||||
|                      "Many to many search is not implemented for the chosen search algorithm.", |                      "Many to many search is not implemented for the chosen search algorithm.", | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     BOOST_ASSERT(parameters.IsValid()); |     BOOST_ASSERT(parameters.IsValid()); | ||||||
| @ -177,21 +178,21 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
|     bool fixed_end = (destination_id == number_of_locations - 1); |     bool fixed_end = (destination_id == number_of_locations - 1); | ||||||
|     if (!IsSupportedParameterCombination(fixed_start, fixed_end, parameters.roundtrip)) |     if (!IsSupportedParameterCombination(fixed_start, fixed_end, parameters.roundtrip)) | ||||||
|     { |     { | ||||||
|         return Error("NotImplemented", "This request is not supported", json_result); |         return Error("NotImplemented", "This request is not supported", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // enforce maximum number of locations for performance reasons
 |     // enforce maximum number of locations for performance reasons
 | ||||||
|     if (max_locations_trip > 0 && static_cast<int>(number_of_locations) > max_locations_trip) |     if (max_locations_trip > 0 && static_cast<int>(number_of_locations) > max_locations_trip) | ||||||
|     { |     { | ||||||
|         return Error("TooBig", "Too many trip coordinates", json_result); |         return Error("TooBig", "Too many trip coordinates", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!CheckAllCoordinates(parameters.coordinates)) |     if (!CheckAllCoordinates(parameters.coordinates)) | ||||||
|     { |     { | ||||||
|         return Error("InvalidValue", "Invalid coordinate value.", json_result); |         return Error("InvalidValue", "Invalid coordinate value.", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!CheckAlgorithms(parameters, algorithms, json_result)) |     if (!CheckAlgorithms(parameters, algorithms, result)) | ||||||
|         return Status::Error; |         return Status::Error; | ||||||
| 
 | 
 | ||||||
|     const auto &facade = algorithms.GetFacade(); |     const auto &facade = algorithms.GetFacade(); | ||||||
| @ -201,14 +202,14 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
|         return Error("NoSegment", |         return Error("NoSegment", | ||||||
|                      std::string("Could not find a matching segment for coordinate ") + |                      std::string("Could not find a matching segment for coordinate ") + | ||||||
|                          std::to_string(phantom_node_pairs.size()), |                          std::to_string(phantom_node_pairs.size()), | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
|     BOOST_ASSERT(phantom_node_pairs.size() == number_of_locations); |     BOOST_ASSERT(phantom_node_pairs.size() == number_of_locations); | ||||||
| 
 | 
 | ||||||
|     if (fixed_start && fixed_end && (source_id >= parameters.coordinates.size() || |     if (fixed_start && fixed_end && (source_id >= parameters.coordinates.size() || | ||||||
|                                      destination_id >= parameters.coordinates.size())) |                                      destination_id >= parameters.coordinates.size())) | ||||||
|     { |     { | ||||||
|         return Error("InvalidValue", "Invalid source or destination value.", json_result); |         return Error("InvalidValue", "Invalid source or destination value.", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs); |     auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs); | ||||||
| @ -231,7 +232,7 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | |||||||
| 
 | 
 | ||||||
|     if (!IsStronglyConnectedComponent(result_duration_table)) |     if (!IsStronglyConnectedComponent(result_duration_table)) | ||||||
|     { |     { | ||||||
|         return Error("NoTrips", "No trip visiting all destinations possible.", json_result); |         return Error("NoTrips", "No trip visiting all destinations possible.", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (fixed_start && fixed_end) |     if (fixed_start && fixed_end) | ||||||
|  | |||||||
| @ -28,16 +28,18 @@ ViaRoutePlugin::ViaRoutePlugin(int max_locations_viaroute, int max_alternatives) | |||||||
| 
 | 
 | ||||||
| Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, | ||||||
|                                      const api::RouteParameters &route_parameters, |                                      const api::RouteParameters &route_parameters, | ||||||
|                                      util::json::Object &json_result) const |                                      osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|     BOOST_ASSERT(route_parameters.IsValid()); |     BOOST_ASSERT(route_parameters.IsValid()); | ||||||
| 
 | 
 | ||||||
|  |     auto& json_result = result.get<util::json::Object>(); | ||||||
|  | 
 | ||||||
|     if (!algorithms.HasShortestPathSearch() && route_parameters.coordinates.size() > 2) |     if (!algorithms.HasShortestPathSearch() && route_parameters.coordinates.size() > 2) | ||||||
|     { |     { | ||||||
|         return Error("NotImplemented", |         return Error("NotImplemented", | ||||||
|                      "Shortest path search is not implemented for the chosen search algorithm. " |                      "Shortest path search is not implemented for the chosen search algorithm. " | ||||||
|                      "Only two coordinates supported.", |                      "Only two coordinates supported.", | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!algorithms.HasDirectShortestPathSearch() && !algorithms.HasShortestPathSearch()) |     if (!algorithms.HasDirectShortestPathSearch() && !algorithms.HasShortestPathSearch()) | ||||||
| @ -45,7 +47,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm | |||||||
|         return Error( |         return Error( | ||||||
|             "NotImplemented", |             "NotImplemented", | ||||||
|             "Direct shortest path search is not implemented for the chosen search algorithm.", |             "Direct shortest path search is not implemented for the chosen search algorithm.", | ||||||
|             json_result); |             result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (max_locations_viaroute > 0 && |     if (max_locations_viaroute > 0 && | ||||||
| @ -55,7 +57,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm | |||||||
|                      "Number of entries " + std::to_string(route_parameters.coordinates.size()) + |                      "Number of entries " + std::to_string(route_parameters.coordinates.size()) + | ||||||
|                          " is higher than current maximum (" + |                          " is higher than current maximum (" + | ||||||
|                          std::to_string(max_locations_viaroute) + ")", |                          std::to_string(max_locations_viaroute) + ")", | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Takes care of alternatives=n and alternatives=true
 |     // Takes care of alternatives=n and alternatives=true
 | ||||||
| @ -65,12 +67,12 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm | |||||||
|         return Error("TooBig", |         return Error("TooBig", | ||||||
|                      "Requested number of alternatives is higher than current maximum (" + |                      "Requested number of alternatives is higher than current maximum (" + | ||||||
|                          std::to_string(max_alternatives) + ")", |                          std::to_string(max_alternatives) + ")", | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!CheckAllCoordinates(route_parameters.coordinates)) |     if (!CheckAllCoordinates(route_parameters.coordinates)) | ||||||
|     { |     { | ||||||
|         return Error("InvalidValue", "Invalid coordinate value.", json_result); |         return Error("InvalidValue", "Invalid coordinate value.", result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Error: first and last points should be waypoints
 |     // Error: first and last points should be waypoints
 | ||||||
| @ -80,10 +82,10 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm | |||||||
|     { |     { | ||||||
|         return Error("InvalidValue", |         return Error("InvalidValue", | ||||||
|                      "First and last coordinates must be specified as waypoints.", |                      "First and last coordinates must be specified as waypoints.", | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!CheckAlgorithms(route_parameters, algorithms, json_result)) |     if (!CheckAlgorithms(route_parameters, algorithms, result)) | ||||||
|         return Status::Error; |         return Status::Error; | ||||||
| 
 | 
 | ||||||
|     const auto &facade = algorithms.GetFacade(); |     const auto &facade = algorithms.GetFacade(); | ||||||
| @ -93,7 +95,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm | |||||||
|         return Error("NoSegment", |         return Error("NoSegment", | ||||||
|                      std::string("Could not find a matching segment for coordinate ") + |                      std::string("Could not find a matching segment for coordinate ") + | ||||||
|                          std::to_string(phantom_node_pairs.size()), |                          std::to_string(phantom_node_pairs.size()), | ||||||
|                      json_result); |                      result); | ||||||
|     } |     } | ||||||
|     BOOST_ASSERT(phantom_node_pairs.size() == route_parameters.coordinates.size()); |     BOOST_ASSERT(phantom_node_pairs.size() == route_parameters.coordinates.size()); | ||||||
| 
 | 
 | ||||||
| @ -175,11 +177,11 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm | |||||||
| 
 | 
 | ||||||
|         if (not_in_same_component) |         if (not_in_same_component) | ||||||
|         { |         { | ||||||
|             return Error("NoRoute", "Impossible route between points", json_result); |             return Error("NoRoute", "Impossible route between points", result); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             return Error("NoRoute", "No route found between points", json_result); |             return Error("NoRoute", "No route found between points", result); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -57,33 +57,37 @@ OSRM &OSRM::operator=(OSRM &&) noexcept = default; | |||||||
| // Forward to implementation
 | // Forward to implementation
 | ||||||
| 
 | 
 | ||||||
| engine::Status OSRM::Route(const engine::api::RouteParameters ¶ms, | engine::Status OSRM::Route(const engine::api::RouteParameters ¶ms, | ||||||
|                            util::json::Object &result) const |                            osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|     return engine_->Route(params, result); |     return engine_->Route(params, result); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| engine::Status OSRM::Table(const engine::api::TableParameters ¶ms, json::Object &result) const | engine::Status OSRM::Table(const engine::api::TableParameters ¶ms, | ||||||
|  |                            osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|     return engine_->Table(params, result); |     return engine_->Table(params, result); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| engine::Status OSRM::Nearest(const engine::api::NearestParameters ¶ms, | engine::Status OSRM::Nearest(const engine::api::NearestParameters ¶ms, | ||||||
|                              json::Object &result) const |                              osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|     return engine_->Nearest(params, result); |     return engine_->Nearest(params, result); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| engine::Status OSRM::Trip(const engine::api::TripParameters ¶ms, json::Object &result) const | engine::Status OSRM::Trip(const engine::api::TripParameters ¶ms, | ||||||
|  |                           osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|     return engine_->Trip(params, result); |     return engine_->Trip(params, result); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| engine::Status OSRM::Match(const engine::api::MatchParameters ¶ms, json::Object &result) const | engine::Status OSRM::Match(const engine::api::MatchParameters ¶ms, | ||||||
|  |                            osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|     return engine_->Match(params, result); |     return engine_->Match(params, result); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| engine::Status OSRM::Tile(const engine::api::TileParameters ¶ms, std::string &result) const | engine::Status OSRM::Tile(const engine::api::TileParameters ¶ms, | ||||||
|  |                           osrm::engine::api::ResultT &result) const | ||||||
| { | { | ||||||
|     return engine_->Tile(params, result); |     return engine_->Tile(params, result); | ||||||
| } | } | ||||||
|  | |||||||
| @ -42,7 +42,7 @@ std::string getWrongOptionHelp(const engine::api::MatchParameters ¶meters) | |||||||
| } // anon. ns
 | } // anon. ns
 | ||||||
| 
 | 
 | ||||||
| engine::Status | engine::Status | ||||||
| MatchService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) | MatchService::RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) | ||||||
| { | { | ||||||
|     result = util::json::Object(); |     result = util::json::Object(); | ||||||
|     auto &json_result = result.get<util::json::Object>(); |     auto &json_result = result.get<util::json::Object>(); | ||||||
| @ -68,7 +68,7 @@ MatchService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &r | |||||||
|     } |     } | ||||||
|     BOOST_ASSERT(parameters->IsValid()); |     BOOST_ASSERT(parameters->IsValid()); | ||||||
| 
 | 
 | ||||||
|     return BaseService::routing_machine.Match(*parameters, json_result); |     return BaseService::routing_machine.Match(*parameters, result); | ||||||
| } | } | ||||||
| } | } | ||||||
| } | } | ||||||
|  | |||||||
| @ -36,7 +36,7 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters ¶meters) | |||||||
| } // anon. ns
 | } // anon. ns
 | ||||||
| 
 | 
 | ||||||
| engine::Status | engine::Status | ||||||
| NearestService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) | NearestService::RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) | ||||||
| { | { | ||||||
|     result = util::json::Object(); |     result = util::json::Object(); | ||||||
|     auto &json_result = result.get<util::json::Object>(); |     auto &json_result = result.get<util::json::Object>(); | ||||||
| @ -62,7 +62,7 @@ NearestService::RunQuery(std::size_t prefix_length, std::string &query, ResultT | |||||||
|     } |     } | ||||||
|     BOOST_ASSERT(parameters->IsValid()); |     BOOST_ASSERT(parameters->IsValid()); | ||||||
| 
 | 
 | ||||||
|     return BaseService::routing_machine.Nearest(*parameters, json_result); |     return BaseService::routing_machine.Nearest(*parameters, result); | ||||||
| } | } | ||||||
| } | } | ||||||
| } | } | ||||||
|  | |||||||
| @ -40,7 +40,7 @@ std::string getWrongOptionHelp(const engine::api::RouteParameters ¶meters) | |||||||
| } // anon. ns
 | } // anon. ns
 | ||||||
| 
 | 
 | ||||||
| engine::Status | engine::Status | ||||||
| RouteService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) | RouteService::RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) | ||||||
| { | { | ||||||
|     result = util::json::Object(); |     result = util::json::Object(); | ||||||
|     auto &json_result = result.get<util::json::Object>(); |     auto &json_result = result.get<util::json::Object>(); | ||||||
| @ -66,7 +66,7 @@ RouteService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &r | |||||||
|     } |     } | ||||||
|     BOOST_ASSERT(parameters->IsValid()); |     BOOST_ASSERT(parameters->IsValid()); | ||||||
| 
 | 
 | ||||||
|     return BaseService::routing_machine.Route(*parameters, json_result); |     return BaseService::routing_machine.Route(*parameters, result); | ||||||
| } | } | ||||||
| } | } | ||||||
| } | } | ||||||
|  | |||||||
| @ -71,7 +71,7 @@ std::string getWrongOptionHelp(const engine::api::TableParameters ¶meters) | |||||||
| } // anon. ns
 | } // anon. ns
 | ||||||
| 
 | 
 | ||||||
| engine::Status | engine::Status | ||||||
| TableService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) | TableService::RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) | ||||||
| { | { | ||||||
|     result = util::json::Object(); |     result = util::json::Object(); | ||||||
|     auto &json_result = result.get<util::json::Object>(); |     auto &json_result = result.get<util::json::Object>(); | ||||||
| @ -97,7 +97,7 @@ TableService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &r | |||||||
|     } |     } | ||||||
|     BOOST_ASSERT(parameters->IsValid()); |     BOOST_ASSERT(parameters->IsValid()); | ||||||
| 
 | 
 | ||||||
|     return BaseService::routing_machine.Table(*parameters, json_result); |     return BaseService::routing_machine.Table(*parameters, result); | ||||||
| } | } | ||||||
| } | } | ||||||
| } | } | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ namespace server | |||||||
| namespace service | namespace service | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| engine::Status TileService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) | engine::Status TileService::RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) | ||||||
| { | { | ||||||
|     auto query_iterator = query.begin(); |     auto query_iterator = query.begin(); | ||||||
|     auto parameters = |     auto parameters = | ||||||
| @ -43,8 +43,7 @@ engine::Status TileService::RunQuery(std::size_t prefix_length, std::string &que | |||||||
|     BOOST_ASSERT(parameters->IsValid()); |     BOOST_ASSERT(parameters->IsValid()); | ||||||
| 
 | 
 | ||||||
|     result = std::string(); |     result = std::string(); | ||||||
|     auto &string_result = result.get<std::string>(); |     return BaseService::routing_machine.Tile(*parameters, result); | ||||||
|     return BaseService::routing_machine.Tile(*parameters, string_result); |  | ||||||
| } | } | ||||||
| } | } | ||||||
| } | } | ||||||
|  | |||||||
| @ -41,7 +41,7 @@ std::string getWrongOptionHelp(const engine::api::TripParameters ¶meters) | |||||||
| } | } | ||||||
| } // anon. ns
 | } // anon. ns
 | ||||||
| 
 | 
 | ||||||
| engine::Status TripService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) | engine::Status TripService::RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) | ||||||
| { | { | ||||||
|     result = util::json::Object(); |     result = util::json::Object(); | ||||||
|     auto &json_result = result.get<util::json::Object>(); |     auto &json_result = result.get<util::json::Object>(); | ||||||
| @ -69,7 +69,7 @@ engine::Status TripService::RunQuery(std::size_t prefix_length, std::string &que | |||||||
|     } |     } | ||||||
|     BOOST_ASSERT(parameters->IsValid()); |     BOOST_ASSERT(parameters->IsValid()); | ||||||
| 
 | 
 | ||||||
|     return BaseService::routing_machine.Trip(*parameters, json_result); |     return BaseService::routing_machine.Trip(*parameters, result); | ||||||
| } | } | ||||||
| } | } | ||||||
| } | } | ||||||
|  | |||||||
| @ -27,7 +27,7 @@ ServiceHandler::ServiceHandler(osrm::EngineConfig &config) : routing_machine(con | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url, | engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url, | ||||||
|                                         service::BaseService::ResultT &result) |                                         osrm::engine::api::ResultT &result) | ||||||
| { | { | ||||||
|     const auto &service_iter = service_map.find(parsed_url.service); |     const auto &service_iter = service_map.find(parsed_url.service); | ||||||
|     if (service_iter == service_map.end()) |     if (service_iter == service_map.end()) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user