Just return NoSegment in map matching if all candidates are empty
This commit is contained in:
		
							parent
							
								
									09a9d6c417
								
							
						
					
					
						commit
						1af59e874d
					
				| @ -47,6 +47,10 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates, | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         auto &candidates = candidates_lists[current_coordinate]; |         auto &candidates = candidates_lists[current_coordinate]; | ||||||
|  |         if (candidates.empty()) | ||||||
|  |         { | ||||||
|  |             continue; | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         // sort by forward id, then by reverse id and then by distance
 |         // sort by forward id, then by reverse id and then by distance
 | ||||||
|         std::sort( |         std::sort( | ||||||
| @ -144,11 +148,14 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters, | |||||||
|     auto candidates_lists = GetPhantomNodesInRange(parameters, search_radiuses); |     auto candidates_lists = GetPhantomNodesInRange(parameters, search_radiuses); | ||||||
| 
 | 
 | ||||||
|     filterCandidates(parameters.coordinates, candidates_lists); |     filterCandidates(parameters.coordinates, candidates_lists); | ||||||
|     if (candidates_lists.size() != parameters.coordinates.size()) |     if (std::all_of(candidates_lists.begin(), candidates_lists.end(), | ||||||
|  |                     [](const std::vector<PhantomNodeWithDistance> &candidates) | ||||||
|  |                     { | ||||||
|  |                         return candidates.empty(); | ||||||
|  |                     })) | ||||||
|     { |     { | ||||||
|         BOOST_ASSERT(candidates_lists.size() < parameters.coordinates.size()); |         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 any coordinate."), | ||||||
|                                       std::to_string(candidates_lists.size()), |  | ||||||
|                      json_result); |                      json_result); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user