make variable names consistent, migrate Plugins

This commit is contained in:
Dennis Luxen
2014-05-08 11:15:19 +02:00
parent 2850a074ea
commit 9587923e55
8 changed files with 147 additions and 145 deletions
+40 -40
View File
@@ -46,66 +46,66 @@ class HelloWorldPlugin : public BasePlugin
void HandleRequest(const RouteParameters &routeParameters, http::Reply &reply)
{
reply.status = http::Reply::ok;
reply.content.push_back("<html><head><title>Hello World Demonstration "
"Document</title></head><body><h1>Hello, World!</h1>");
reply.content.push_back("<pre>");
reply.content.push_back("zoom level: ");
intToString(routeParameters.zoomLevel, temp_string);
reply.content.push_back(temp_string);
reply.content.push_back("\nchecksum: ");
reply.content.emplace_back("<html><head><title>Hello World Demonstration "
"Document</title></head><body><h1>Hello, World!</h1>");
reply.content.emplace_back("<pre>");
reply.content.emplace_back("zoom level: ");
intToString(routeParameters.zoom_level, temp_string);
reply.content.emplace_back(temp_string);
reply.content.emplace_back("\nchecksum: ");
intToString(routeParameters.check_sum, temp_string);
reply.content.push_back(temp_string);
reply.content.push_back("\ninstructions: ");
reply.content.push_back((routeParameters.printInstructions ? "yes" : "no"));
reply.content.push_back(temp_string);
reply.content.push_back("\ngeometry: ");
reply.content.push_back((routeParameters.geometry ? "yes" : "no"));
reply.content.push_back("\ncompression: ");
reply.content.push_back((routeParameters.compression ? "yes" : "no"));
reply.content.push_back("\noutput format: ");
reply.content.push_back(routeParameters.outputFormat);
reply.content.push_back("\njson parameter: ");
reply.content.push_back(routeParameters.jsonpParameter);
reply.content.push_back("\nlanguage: ");
reply.content.push_back(routeParameters.language);
reply.content.push_back("\nNumber of locations: ");
reply.content.emplace_back(temp_string);
reply.content.emplace_back("\ninstructions: ");
reply.content.emplace_back((routeParameters.print_instructions ? "yes" : "no"));
reply.content.emplace_back(temp_string);
reply.content.emplace_back("\ngeometry: ");
reply.content.emplace_back((routeParameters.geometry ? "yes" : "no"));
reply.content.emplace_back("\ncompression: ");
reply.content.emplace_back((routeParameters.compression ? "yes" : "no"));
reply.content.emplace_back("\noutput format: ");
reply.content.emplace_back(routeParameters.output_format);
reply.content.emplace_back("\njson parameter: ");
reply.content.emplace_back(routeParameters.jsonp_parameter);
reply.content.emplace_back("\nlanguage: ");
reply.content.emplace_back(routeParameters.language);
reply.content.emplace_back("\nNumber of locations: ");
intToString(routeParameters.coordinates.size(), temp_string);
reply.content.push_back(temp_string);
reply.content.push_back("\n");
reply.content.emplace_back(temp_string);
reply.content.emplace_back("\n");
unsigned counter = 0;
for (const FixedPointCoordinate &coordinate : routeParameters.coordinates)
{
reply.content.push_back(" [");
reply.content.emplace_back(" [");
intToString(counter, temp_string);
reply.content.push_back(temp_string);
reply.content.push_back("] ");
reply.content.emplace_back(temp_string);
reply.content.emplace_back("] ");
doubleToString(coordinate.lat / COORDINATE_PRECISION, temp_string);
reply.content.push_back(temp_string);
reply.content.push_back(",");
reply.content.emplace_back(temp_string);
reply.content.emplace_back(",");
doubleToString(coordinate.lon / COORDINATE_PRECISION, temp_string);
reply.content.push_back(temp_string);
reply.content.push_back("\n");
reply.content.emplace_back(temp_string);
reply.content.emplace_back("\n");
++counter;
}
reply.content.push_back("Number of hints: ");
reply.content.emplace_back("Number of hints: ");
intToString(routeParameters.hints.size(), temp_string);
reply.content.push_back(temp_string);
reply.content.push_back("\n");
reply.content.emplace_back(temp_string);
reply.content.emplace_back("\n");
counter = 0;
for (const std::string &current_string : routeParameters.hints)
{
reply.content.push_back(" [");
reply.content.emplace_back(" [");
intToString(counter, temp_string);
reply.content.push_back(temp_string);
reply.content.push_back("] ");
reply.content.push_back(current_string);
reply.content.push_back("\n");
reply.content.emplace_back(temp_string);
reply.content.emplace_back("] ");
reply.content.emplace_back(current_string);
reply.content.emplace_back("\n");
++counter;
}
reply.content.push_back("</pre></body></html>");
reply.content.emplace_back("</pre></body></html>");
}
private:
+20 -19
View File
@@ -39,10 +39,10 @@ template <class DataFacadeT> class LocatePlugin : public BasePlugin
explicit LocatePlugin(DataFacadeT *facade) : descriptor_string("locate"), facade(facade) {}
const std::string GetDescriptor() const { return descriptor_string; }
void HandleRequest(const RouteParameters &routeParameters, http::Reply &reply)
void HandleRequest(const RouteParameters &route_parameters, http::Reply &reply)
{
// check number of parameters
if (routeParameters.coordinates.empty() || !routeParameters.coordinates.front().isValid())
if (route_parameters.coordinates.empty() || !route_parameters.coordinates.front().isValid())
{
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
@@ -53,37 +53,38 @@ template <class DataFacadeT> class LocatePlugin : public BasePlugin
std::string tmp;
// json
if (!routeParameters.jsonpParameter.empty())
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.push_back(routeParameters.jsonpParameter);
reply.content.push_back("(");
reply.content.emplace_back(route_parameters.jsonp_parameter);
reply.content.emplace_back("(");
}
reply.status = http::Reply::ok;
reply.content.push_back("{");
if (!facade->LocateClosestEndPointForCoordinate(routeParameters.coordinates.front(), result))
reply.content.emplace_back("{");
if (!facade->LocateClosestEndPointForCoordinate(route_parameters.coordinates.front(),
result))
{
reply.content.push_back("\"status\":207,");
reply.content.push_back("\"mapped_coordinate\":[]");
reply.content.emplace_back("\"status\":207,");
reply.content.emplace_back("\"mapped_coordinate\":[]");
}
else
{
// Write coordinate to stream
reply.status = http::Reply::ok;
reply.content.push_back("\"status\":0,");
reply.content.push_back("\"mapped_coordinate\":");
reply.content.emplace_back("\"status\":0,");
reply.content.emplace_back("\"mapped_coordinate\":");
FixedPointCoordinate::convertInternalLatLonToString(result.lat, tmp);
reply.content.push_back("[");
reply.content.push_back(tmp);
reply.content.emplace_back("[");
reply.content.emplace_back(tmp);
FixedPointCoordinate::convertInternalLatLonToString(result.lon, tmp);
reply.content.push_back(",");
reply.content.push_back(tmp);
reply.content.push_back("]");
reply.content.emplace_back(",");
reply.content.emplace_back(tmp);
reply.content.emplace_back("]");
}
reply.content.push_back("}");
reply.content.emplace_back("}");
reply.headers.resize(3);
if (!routeParameters.jsonpParameter.empty())
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.push_back(")");
reply.content.emplace_back(")");
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "text/javascript";
reply.headers[2].name = "Content-Disposition";
+19 -19
View File
@@ -49,15 +49,15 @@ template <class DataFacadeT> class NearestPlugin : public BasePlugin
const std::string GetDescriptor() const { return descriptor_string; }
void HandleRequest(const RouteParameters &routeParameters, http::Reply &reply)
void HandleRequest(const RouteParameters &route_parameters, http::Reply &reply)
{
// check number of parameters
if (routeParameters.coordinates.empty())
if (route_parameters.coordinates.empty())
{
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
}
if (!routeParameters.coordinates.front().isValid())
if (!route_parameters.coordinates.front().isValid())
{
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
@@ -65,48 +65,48 @@ template <class DataFacadeT> class NearestPlugin : public BasePlugin
PhantomNode result;
facade->FindPhantomNodeForCoordinate(
routeParameters.coordinates.front(), result, routeParameters.zoomLevel);
route_parameters.coordinates.front(), result, route_parameters.zoom_level);
// json
if (!routeParameters.jsonpParameter.empty())
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.push_back(routeParameters.jsonpParameter);
reply.content.push_back("(");
reply.content.emplace_back(route_parameters.jsonp_parameter);
reply.content.emplace_back("(");
}
reply.status = http::Reply::ok;
reply.content.push_back("{\"status\":");
reply.content.emplace_back("{\"status\":");
if (SPECIAL_NODEID != result.forward_node_id)
{
reply.content.push_back("0,");
reply.content.emplace_back("0,");
}
else
{
reply.content.push_back("207,");
reply.content.emplace_back("207,");
}
reply.content.push_back("\"mapped_coordinate\":[");
reply.content.emplace_back("\"mapped_coordinate\":[");
std::string temp_string;
if (SPECIAL_NODEID != result.forward_node_id)
{
FixedPointCoordinate::convertInternalLatLonToString(result.location.lat, temp_string);
reply.content.push_back(temp_string);
reply.content.emplace_back(temp_string);
FixedPointCoordinate::convertInternalLatLonToString(result.location.lon, temp_string);
reply.content.push_back(",");
reply.content.push_back(temp_string);
reply.content.emplace_back(",");
reply.content.emplace_back(temp_string);
}
reply.content.push_back("],\"name\":\"");
reply.content.emplace_back("],\"name\":\"");
if (SPECIAL_NODEID != result.forward_node_id)
{
facade->GetName(result.name_id, temp_string);
reply.content.push_back(temp_string);
reply.content.emplace_back(temp_string);
}
reply.content.push_back("\"}");
reply.content.emplace_back("\"}");
reply.headers.resize(3);
if (!routeParameters.jsonpParameter.empty())
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.push_back(")");
reply.content.emplace_back(")");
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "text/javascript";
reply.headers[2].name = "Content-Disposition";
+13 -13
View File
@@ -38,29 +38,29 @@ template <class DataFacadeT> class TimestampPlugin : public BasePlugin
{
}
const std::string GetDescriptor() const { return descriptor_string; }
void HandleRequest(const RouteParameters &routeParameters, http::Reply &reply)
void HandleRequest(const RouteParameters &route_parameters, http::Reply &reply)
{
std::string tmp;
// json
if (!routeParameters.jsonpParameter.empty())
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.push_back(routeParameters.jsonpParameter);
reply.content.push_back("(");
reply.content.emplace_back(route_parameters.jsonp_parameter);
reply.content.emplace_back("(");
}
reply.status = http::Reply::ok;
reply.content.push_back("{");
reply.content.push_back("\"status\":");
reply.content.push_back("0,");
reply.content.push_back("\"timestamp\":\"");
reply.content.push_back(facade->GetTimestamp());
reply.content.push_back("\"");
reply.content.push_back("}");
reply.content.emplace_back("{");
reply.content.emplace_back("\"status\":");
reply.content.emplace_back("0,");
reply.content.emplace_back("\"timestamp\":\"");
reply.content.emplace_back(facade->GetTimestamp());
reply.content.emplace_back("\"");
reply.content.emplace_back("}");
reply.headers.resize(3);
if (!routeParameters.jsonpParameter.empty())
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.push_back(")");
reply.content.emplace_back(")");
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "text/javascript";
reply.headers[2].name = "Content-Disposition";
+14 -13
View File
@@ -108,7 +108,7 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
}
facade->FindPhantomNodeForCoordinate(raw_route.raw_via_node_coordinates[i],
phantom_node_vector[i],
routeParameters.zoomLevel);
routeParameters.zoom_level);
}
PhantomNodes current_phantom_node_pair;
@@ -119,9 +119,10 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
raw_route.segment_end_coordinates.emplace_back(current_phantom_node_pair);
}
if ((routeParameters.alternateRoute) && (1 == raw_route.segment_end_coordinates.size()))
if ((routeParameters.alternate_route) && (1 == raw_route.segment_end_coordinates.size()))
{
search_engine_ptr->alternative_path(raw_route.segment_end_coordinates.front(), raw_route);
search_engine_ptr->alternative_path(raw_route.segment_end_coordinates.front(),
raw_route);
}
else
{
@@ -134,19 +135,19 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
}
reply.status = http::Reply::ok;
if (!routeParameters.jsonpParameter.empty())
if (!routeParameters.jsonp_parameter.empty())
{
reply.content.push_back(routeParameters.jsonpParameter);
reply.content.push_back("(");
reply.content.emplace_back(routeParameters.jsonp_parameter);
reply.content.emplace_back("(");
}
DescriptorConfig descriptor_config;
auto iter = descriptorTable.find(routeParameters.outputFormat);
auto iter = descriptorTable.find(routeParameters.output_format);
unsigned descriptor_type = (iter != descriptorTable.end() ? iter->second : 0);
descriptor_config.zoom_level = routeParameters.zoomLevel;
descriptor_config.instructions = routeParameters.printInstructions;
descriptor_config.zoom_level = routeParameters.zoom_level;
descriptor_config.instructions = routeParameters.print_instructions;
descriptor_config.geometry = routeParameters.geometry;
descriptor_config.encode_geometry = routeParameters.compression;
@@ -170,9 +171,9 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
descriptor->SetConfig(descriptor_config);
descriptor->Run(raw_route, phantom_nodes, facade, reply);
if (!routeParameters.jsonpParameter.empty())
if (!routeParameters.jsonp_parameter.empty())
{
reply.content.push_back(")\n");
reply.content.emplace_back(")\n");
}
reply.headers.resize(3);
reply.headers[0].name = "Content-Length";
@@ -189,7 +190,7 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
switch (descriptor_type)
{
case 0:
if (!routeParameters.jsonpParameter.empty())
if (!routeParameters.jsonp_parameter.empty())
{
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "text/javascript";
@@ -213,7 +214,7 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
break;
default:
if (!routeParameters.jsonpParameter.empty())
if (!routeParameters.jsonp_parameter.empty())
{
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "text/javascript";