Uses current JSON format if number of results requested is 1
This commit is contained in:
parent
38117df11b
commit
b9eb936cac
@ -59,6 +59,10 @@ template <class DataFacadeT> class NearestPlugin : public BasePlugin
|
|||||||
phantom_node_vector,
|
phantom_node_vector,
|
||||||
route_parameters.zoom_level,
|
route_parameters.zoom_level,
|
||||||
number_of_results);
|
number_of_results);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JSON::Object json_result;
|
JSON::Object json_result;
|
||||||
if (phantom_node_vector.empty() || !phantom_node_vector.front().isValid())
|
if (phantom_node_vector.empty() || !phantom_node_vector.front().isValid())
|
||||||
{
|
{
|
||||||
@ -68,6 +72,9 @@ template <class DataFacadeT> class NearestPlugin : public BasePlugin
|
|||||||
{
|
{
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
json_result.values["status"] = 0;
|
json_result.values["status"] = 0;
|
||||||
|
|
||||||
|
if (number_of_results > 1)
|
||||||
|
{
|
||||||
JSON::Array results;
|
JSON::Array results;
|
||||||
|
|
||||||
int vector_length = phantom_node_vector.size();
|
int vector_length = phantom_node_vector.size();
|
||||||
@ -87,6 +94,19 @@ template <class DataFacadeT> class NearestPlugin : public BasePlugin
|
|||||||
}
|
}
|
||||||
json_result.values["results"] = results;
|
json_result.values["results"] = results;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JSON::Array json_coordinate;
|
||||||
|
json_coordinate.values.push_back(phantom_node_vector.front().location.lat /
|
||||||
|
COORDINATE_PRECISION);
|
||||||
|
json_coordinate.values.push_back(phantom_node_vector.front().location.lon /
|
||||||
|
COORDINATE_PRECISION);
|
||||||
|
json_result.values["mapped_coordinate"] = json_coordinate;
|
||||||
|
std::string temp_string;
|
||||||
|
facade->GetName(phantom_node_vector.front().name_id, temp_string);
|
||||||
|
json_result.values["name"] = temp_string;
|
||||||
|
}
|
||||||
|
}
|
||||||
JSON::render(reply.content, json_result);
|
JSON::render(reply.content, json_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user