Added setting 'data_version' to all flatbuffers response functions.
This commit is contained in:
		
							parent
							
								
									ce71e08ef1
								
							
						
					
					
						commit
						80e1abba0c
					
				| @ -49,10 +49,22 @@ class MatchAPI final : public RouteAPI | |||||||
|                       const std::vector<InternalRouteResult> &sub_routes, |                       const std::vector<InternalRouteResult> &sub_routes, | ||||||
|                       flatbuffers::FlatBufferBuilder &fb_result) const |                       flatbuffers::FlatBufferBuilder &fb_result) const | ||||||
|     { |     { | ||||||
|  |         auto data_timestamp = facade.GetTimestamp(); | ||||||
|  |         boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none; | ||||||
|  |         if (!data_timestamp.empty()) | ||||||
|  |         { | ||||||
|  |             data_version_string = fb_result.CreateString(data_timestamp); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         auto response = MakeFBResponse(sub_routes, fb_result, [this, &fb_result, &sub_matchings]() { |         auto response = MakeFBResponse(sub_routes, fb_result, [this, &fb_result, &sub_matchings]() { | ||||||
|             return MakeTracepoints(fb_result, sub_matchings); |             return MakeTracepoints(fb_result, sub_matchings); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  |         if (data_version_string) | ||||||
|  |         { | ||||||
|  |             response.add_data_version(*data_version_string); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         fb_result.Finish(response.Finish()); |         fb_result.Finish(response.Finish()); | ||||||
|     } |     } | ||||||
|     void MakeResponse(const std::vector<map_matching::SubMatching> &sub_matchings, |     void MakeResponse(const std::vector<map_matching::SubMatching> &sub_matchings, | ||||||
|  | |||||||
| @ -47,6 +47,13 @@ class NearestAPI final : public BaseAPI | |||||||
|     void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes, |     void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes, | ||||||
|                       flatbuffers::FlatBufferBuilder &fb_result) const |                       flatbuffers::FlatBufferBuilder &fb_result) const | ||||||
|     { |     { | ||||||
|  |         auto data_timestamp = facade.GetTimestamp(); | ||||||
|  |         boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none; | ||||||
|  |         if (!data_timestamp.empty()) | ||||||
|  |         { | ||||||
|  |             data_version_string = fb_result.CreateString(data_timestamp); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints; |         std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints; | ||||||
|         waypoints.resize(phantom_nodes.front().size()); |         waypoints.resize(phantom_nodes.front().size()); | ||||||
|         std::transform(phantom_nodes.front().begin(), |         std::transform(phantom_nodes.front().begin(), | ||||||
| @ -67,6 +74,10 @@ class NearestAPI final : public BaseAPI | |||||||
|         auto waypoints_vector = fb_result.CreateVector(waypoints); |         auto waypoints_vector = fb_result.CreateVector(waypoints); | ||||||
|         fbresult::FBResultBuilder response(fb_result); |         fbresult::FBResultBuilder response(fb_result); | ||||||
|         response.add_waypoints(waypoints_vector); |         response.add_waypoints(waypoints_vector); | ||||||
|  |         if (data_version_string) | ||||||
|  |         { | ||||||
|  |             response.add_data_version(*data_version_string); | ||||||
|  |         } | ||||||
|         fb_result.Finish(response.Finish()); |         fb_result.Finish(response.Finish()); | ||||||
|     } |     } | ||||||
|     void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes, |     void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes, | ||||||
|  | |||||||
| @ -72,6 +72,13 @@ class TableAPI final : public BaseAPI | |||||||
|         auto number_of_sources = parameters.sources.size(); |         auto number_of_sources = parameters.sources.size(); | ||||||
|         auto number_of_destinations = parameters.destinations.size(); |         auto number_of_destinations = parameters.destinations.size(); | ||||||
| 
 | 
 | ||||||
|  |         auto data_timestamp = facade.GetTimestamp(); | ||||||
|  |         boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none; | ||||||
|  |         if (!data_timestamp.empty()) | ||||||
|  |         { | ||||||
|  |             data_version_string = fb_result.CreateString(data_timestamp); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         // symmetric case
 |         // symmetric case
 | ||||||
|         flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> sources; |         flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> sources; | ||||||
|         if (parameters.sources.empty()) |         if (parameters.sources.empty()) | ||||||
| @ -134,7 +141,10 @@ class TableAPI final : public BaseAPI | |||||||
|         auto table_buffer = table.Finish(); |         auto table_buffer = table.Finish(); | ||||||
| 
 | 
 | ||||||
|         fbresult::FBResultBuilder response(fb_result); |         fbresult::FBResultBuilder response(fb_result); | ||||||
| 
 |         if (data_version_string) | ||||||
|  |         { | ||||||
|  |             response.add_data_version(*data_version_string); | ||||||
|  |         } | ||||||
|         response.add_table(table_buffer); |         response.add_table(table_buffer); | ||||||
|         response.add_waypoints(sources); |         response.add_waypoints(sources); | ||||||
|         fb_result.Finish(response.Finish()); |         fb_result.Finish(response.Finish()); | ||||||
|  | |||||||
| @ -47,11 +47,22 @@ class TripAPI final : public RouteAPI | |||||||
|                       const std::vector<PhantomNode> &phantoms, |                       const std::vector<PhantomNode> &phantoms, | ||||||
|                       flatbuffers::FlatBufferBuilder &fb_result) const |                       flatbuffers::FlatBufferBuilder &fb_result) const | ||||||
|     { |     { | ||||||
|  |         auto data_timestamp = facade.GetTimestamp(); | ||||||
|  |         boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none; | ||||||
|  |         if (!data_timestamp.empty()) | ||||||
|  |         { | ||||||
|  |             data_version_string = fb_result.CreateString(data_timestamp); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         auto response = |         auto response = | ||||||
|             MakeFBResponse(sub_routes, fb_result, [this, &fb_result, &sub_trips, &phantoms]() { |             MakeFBResponse(sub_routes, fb_result, [this, &fb_result, &sub_trips, &phantoms]() { | ||||||
|                 return MakeWaypoints(fb_result, sub_trips, phantoms); |                 return MakeWaypoints(fb_result, sub_trips, phantoms); | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|  |         if (data_version_string) | ||||||
|  |         { | ||||||
|  |             response.add_data_version(*data_version_string); | ||||||
|  |         } | ||||||
|         fb_result.Finish(response.Finish()); |         fb_result.Finish(response.Finish()); | ||||||
|     } |     } | ||||||
|     void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips, |     void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user