make variable names consistent, migrate Plugins
This commit is contained in:
parent
2850a074ea
commit
9587923e55
@ -32,51 +32,51 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <boost/fusion/include/at_c.hpp>
|
#include <boost/fusion/include/at_c.hpp>
|
||||||
|
|
||||||
RouteParameters::RouteParameters()
|
RouteParameters::RouteParameters()
|
||||||
: zoomLevel(18), printInstructions(false), alternateRoute(true), geometry(true),
|
: zoom_level(18), print_instructions(false), alternate_route(true), geometry(true),
|
||||||
compression(true), deprecatedAPI(false), check_sum(-1)
|
compression(true), deprecatedAPI(false), check_sum(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteParameters::setZoomLevel(const short i)
|
void RouteParameters::setZoomLevel(const short level)
|
||||||
{
|
{
|
||||||
if (18 >= i && 0 <= i)
|
if (18 >= level && 0 <= level)
|
||||||
{
|
{
|
||||||
zoomLevel = i;
|
zoom_level = level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteParameters::setAlternateRouteFlag(const bool b) { alternateRoute = b; }
|
void RouteParameters::setAlternateRouteFlag(const bool flag) { alternate_route = flag; }
|
||||||
|
|
||||||
void RouteParameters::setDeprecatedAPIFlag(const std::string &) { deprecatedAPI = true; }
|
void RouteParameters::setDeprecatedAPIFlag(const std::string &) { deprecatedAPI = true; }
|
||||||
|
|
||||||
void RouteParameters::setChecksum(const unsigned c) { check_sum = c; }
|
void RouteParameters::setChecksum(const unsigned sum) { check_sum = sum; }
|
||||||
|
|
||||||
void RouteParameters::setInstructionFlag(const bool b) { printInstructions = b; }
|
void RouteParameters::setInstructionFlag(const bool flag) { print_instructions = flag; }
|
||||||
|
|
||||||
void RouteParameters::setService(const std::string &s) { service = s; }
|
void RouteParameters::setService(const std::string &service_string) { service = service_string; }
|
||||||
|
|
||||||
void RouteParameters::setOutputFormat(const std::string &s) { outputFormat = s; }
|
void RouteParameters::setOutputFormat(const std::string &format) { output_format = format; }
|
||||||
|
|
||||||
void RouteParameters::setJSONpParameter(const std::string &s) { jsonpParameter = s; }
|
void RouteParameters::setJSONpParameter(const std::string ¶meter) { jsonp_parameter = parameter; }
|
||||||
|
|
||||||
void RouteParameters::addHint(const std::string &s)
|
void RouteParameters::addHint(const std::string &hint)
|
||||||
{
|
{
|
||||||
hints.resize(coordinates.size());
|
hints.resize(coordinates.size());
|
||||||
if (!hints.empty())
|
if (!hints.empty())
|
||||||
{
|
{
|
||||||
hints.back() = s;
|
hints.back() = hint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteParameters::setLanguage(const std::string &s) { language = s; }
|
void RouteParameters::setLanguage(const std::string &language_string) { language = language_string; }
|
||||||
|
|
||||||
void RouteParameters::setGeometryFlag(const bool b) { geometry = b; }
|
void RouteParameters::setGeometryFlag(const bool flag) { geometry = flag; }
|
||||||
|
|
||||||
void RouteParameters::setCompressionFlag(const bool b) { compression = b; }
|
void RouteParameters::setCompressionFlag(const bool flag) { compression = flag; }
|
||||||
|
|
||||||
void RouteParameters::addCoordinate(const boost::fusion::vector<double, double> &arg_)
|
void RouteParameters::addCoordinate(const boost::fusion::vector<double, double> &transmitted_coordinates)
|
||||||
{
|
{
|
||||||
int lat = COORDINATE_PRECISION * boost::fusion::at_c<0>(arg_);
|
int lat = COORDINATE_PRECISION * boost::fusion::at_c<0>(transmitted_coordinates);
|
||||||
int lon = COORDINATE_PRECISION * boost::fusion::at_c<1>(arg_);
|
int lon = COORDINATE_PRECISION * boost::fusion::at_c<1>(transmitted_coordinates);
|
||||||
coordinates.push_back(FixedPointCoordinate(lat, lon));
|
coordinates.emplace_back(lat, lon);
|
||||||
}
|
}
|
||||||
|
@ -39,42 +39,42 @@ struct RouteParameters
|
|||||||
{
|
{
|
||||||
RouteParameters();
|
RouteParameters();
|
||||||
|
|
||||||
void setZoomLevel(const short i);
|
void setZoomLevel(const short level);
|
||||||
|
|
||||||
void setAlternateRouteFlag(const bool b);
|
void setAlternateRouteFlag(const bool flag);
|
||||||
|
|
||||||
void setDeprecatedAPIFlag(const std::string &);
|
void setDeprecatedAPIFlag(const std::string &);
|
||||||
|
|
||||||
void setChecksum(const unsigned c);
|
void setChecksum(const unsigned check_sum);
|
||||||
|
|
||||||
void setInstructionFlag(const bool b);
|
void setInstructionFlag(const bool flag);
|
||||||
|
|
||||||
void setService(const std::string &s);
|
void setService(const std::string &service);
|
||||||
|
|
||||||
void setOutputFormat(const std::string &s);
|
void setOutputFormat(const std::string &format);
|
||||||
|
|
||||||
void setJSONpParameter(const std::string &s);
|
void setJSONpParameter(const std::string ¶meter);
|
||||||
|
|
||||||
void addHint(const std::string &s);
|
void addHint(const std::string &hint);
|
||||||
|
|
||||||
void setLanguage(const std::string &s);
|
void setLanguage(const std::string &language);
|
||||||
|
|
||||||
void setGeometryFlag(const bool b);
|
void setGeometryFlag(const bool flag);
|
||||||
|
|
||||||
void setCompressionFlag(const bool b);
|
void setCompressionFlag(const bool flag);
|
||||||
|
|
||||||
void addCoordinate(const boost::fusion::vector<double, double> &arg_);
|
void addCoordinate(const boost::fusion::vector<double, double> &coordinates);
|
||||||
|
|
||||||
short zoomLevel;
|
short zoom_level;
|
||||||
bool printInstructions;
|
bool print_instructions;
|
||||||
bool alternateRoute;
|
bool alternate_route;
|
||||||
bool geometry;
|
bool geometry;
|
||||||
bool compression;
|
bool compression;
|
||||||
bool deprecatedAPI;
|
bool deprecatedAPI;
|
||||||
unsigned check_sum;
|
unsigned check_sum;
|
||||||
std::string service;
|
std::string service;
|
||||||
std::string outputFormat;
|
std::string output_format;
|
||||||
std::string jsonpParameter;
|
std::string jsonp_parameter;
|
||||||
std::string language;
|
std::string language;
|
||||||
std::vector<std::string> hints;
|
std::vector<std::string> hints;
|
||||||
std::vector<FixedPointCoordinate> coordinates;
|
std::vector<FixedPointCoordinate> coordinates;
|
||||||
|
@ -46,66 +46,66 @@ class HelloWorldPlugin : public BasePlugin
|
|||||||
void HandleRequest(const RouteParameters &routeParameters, http::Reply &reply)
|
void HandleRequest(const RouteParameters &routeParameters, http::Reply &reply)
|
||||||
{
|
{
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
reply.content.push_back("<html><head><title>Hello World Demonstration "
|
reply.content.emplace_back("<html><head><title>Hello World Demonstration "
|
||||||
"Document</title></head><body><h1>Hello, World!</h1>");
|
"Document</title></head><body><h1>Hello, World!</h1>");
|
||||||
reply.content.push_back("<pre>");
|
reply.content.emplace_back("<pre>");
|
||||||
reply.content.push_back("zoom level: ");
|
reply.content.emplace_back("zoom level: ");
|
||||||
intToString(routeParameters.zoomLevel, temp_string);
|
intToString(routeParameters.zoom_level, temp_string);
|
||||||
reply.content.push_back(temp_string);
|
reply.content.emplace_back(temp_string);
|
||||||
reply.content.push_back("\nchecksum: ");
|
reply.content.emplace_back("\nchecksum: ");
|
||||||
intToString(routeParameters.check_sum, temp_string);
|
intToString(routeParameters.check_sum, temp_string);
|
||||||
reply.content.push_back(temp_string);
|
reply.content.emplace_back(temp_string);
|
||||||
reply.content.push_back("\ninstructions: ");
|
reply.content.emplace_back("\ninstructions: ");
|
||||||
reply.content.push_back((routeParameters.printInstructions ? "yes" : "no"));
|
reply.content.emplace_back((routeParameters.print_instructions ? "yes" : "no"));
|
||||||
reply.content.push_back(temp_string);
|
reply.content.emplace_back(temp_string);
|
||||||
reply.content.push_back("\ngeometry: ");
|
reply.content.emplace_back("\ngeometry: ");
|
||||||
reply.content.push_back((routeParameters.geometry ? "yes" : "no"));
|
reply.content.emplace_back((routeParameters.geometry ? "yes" : "no"));
|
||||||
reply.content.push_back("\ncompression: ");
|
reply.content.emplace_back("\ncompression: ");
|
||||||
reply.content.push_back((routeParameters.compression ? "yes" : "no"));
|
reply.content.emplace_back((routeParameters.compression ? "yes" : "no"));
|
||||||
reply.content.push_back("\noutput format: ");
|
reply.content.emplace_back("\noutput format: ");
|
||||||
reply.content.push_back(routeParameters.outputFormat);
|
reply.content.emplace_back(routeParameters.output_format);
|
||||||
reply.content.push_back("\njson parameter: ");
|
reply.content.emplace_back("\njson parameter: ");
|
||||||
reply.content.push_back(routeParameters.jsonpParameter);
|
reply.content.emplace_back(routeParameters.jsonp_parameter);
|
||||||
reply.content.push_back("\nlanguage: ");
|
reply.content.emplace_back("\nlanguage: ");
|
||||||
reply.content.push_back(routeParameters.language);
|
reply.content.emplace_back(routeParameters.language);
|
||||||
reply.content.push_back("\nNumber of locations: ");
|
reply.content.emplace_back("\nNumber of locations: ");
|
||||||
intToString(routeParameters.coordinates.size(), temp_string);
|
intToString(routeParameters.coordinates.size(), temp_string);
|
||||||
reply.content.push_back(temp_string);
|
reply.content.emplace_back(temp_string);
|
||||||
reply.content.push_back("\n");
|
reply.content.emplace_back("\n");
|
||||||
|
|
||||||
unsigned counter = 0;
|
unsigned counter = 0;
|
||||||
for (const FixedPointCoordinate &coordinate : routeParameters.coordinates)
|
for (const FixedPointCoordinate &coordinate : routeParameters.coordinates)
|
||||||
{
|
{
|
||||||
reply.content.push_back(" [");
|
reply.content.emplace_back(" [");
|
||||||
intToString(counter, temp_string);
|
intToString(counter, temp_string);
|
||||||
reply.content.push_back(temp_string);
|
reply.content.emplace_back(temp_string);
|
||||||
reply.content.push_back("] ");
|
reply.content.emplace_back("] ");
|
||||||
doubleToString(coordinate.lat / COORDINATE_PRECISION, temp_string);
|
doubleToString(coordinate.lat / COORDINATE_PRECISION, temp_string);
|
||||||
reply.content.push_back(temp_string);
|
reply.content.emplace_back(temp_string);
|
||||||
reply.content.push_back(",");
|
reply.content.emplace_back(",");
|
||||||
doubleToString(coordinate.lon / COORDINATE_PRECISION, temp_string);
|
doubleToString(coordinate.lon / COORDINATE_PRECISION, temp_string);
|
||||||
reply.content.push_back(temp_string);
|
reply.content.emplace_back(temp_string);
|
||||||
reply.content.push_back("\n");
|
reply.content.emplace_back("\n");
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.content.push_back("Number of hints: ");
|
reply.content.emplace_back("Number of hints: ");
|
||||||
intToString(routeParameters.hints.size(), temp_string);
|
intToString(routeParameters.hints.size(), temp_string);
|
||||||
reply.content.push_back(temp_string);
|
reply.content.emplace_back(temp_string);
|
||||||
reply.content.push_back("\n");
|
reply.content.emplace_back("\n");
|
||||||
|
|
||||||
counter = 0;
|
counter = 0;
|
||||||
for (const std::string ¤t_string : routeParameters.hints)
|
for (const std::string ¤t_string : routeParameters.hints)
|
||||||
{
|
{
|
||||||
reply.content.push_back(" [");
|
reply.content.emplace_back(" [");
|
||||||
intToString(counter, temp_string);
|
intToString(counter, temp_string);
|
||||||
reply.content.push_back(temp_string);
|
reply.content.emplace_back(temp_string);
|
||||||
reply.content.push_back("] ");
|
reply.content.emplace_back("] ");
|
||||||
reply.content.push_back(current_string);
|
reply.content.emplace_back(current_string);
|
||||||
reply.content.push_back("\n");
|
reply.content.emplace_back("\n");
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
reply.content.push_back("</pre></body></html>");
|
reply.content.emplace_back("</pre></body></html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -39,10 +39,10 @@ template <class DataFacadeT> class LocatePlugin : public BasePlugin
|
|||||||
explicit LocatePlugin(DataFacadeT *facade) : descriptor_string("locate"), facade(facade) {}
|
explicit LocatePlugin(DataFacadeT *facade) : descriptor_string("locate"), facade(facade) {}
|
||||||
const std::string GetDescriptor() const { return descriptor_string; }
|
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
|
// 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);
|
reply = http::Reply::StockReply(http::Reply::badRequest);
|
||||||
return;
|
return;
|
||||||
@ -53,37 +53,38 @@ template <class DataFacadeT> class LocatePlugin : public BasePlugin
|
|||||||
std::string tmp;
|
std::string tmp;
|
||||||
// json
|
// json
|
||||||
|
|
||||||
if (!routeParameters.jsonpParameter.empty())
|
if (!route_parameters.jsonp_parameter.empty())
|
||||||
{
|
{
|
||||||
reply.content.push_back(routeParameters.jsonpParameter);
|
reply.content.emplace_back(route_parameters.jsonp_parameter);
|
||||||
reply.content.push_back("(");
|
reply.content.emplace_back("(");
|
||||||
}
|
}
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
reply.content.push_back("{");
|
reply.content.emplace_back("{");
|
||||||
if (!facade->LocateClosestEndPointForCoordinate(routeParameters.coordinates.front(), result))
|
if (!facade->LocateClosestEndPointForCoordinate(route_parameters.coordinates.front(),
|
||||||
|
result))
|
||||||
{
|
{
|
||||||
reply.content.push_back("\"status\":207,");
|
reply.content.emplace_back("\"status\":207,");
|
||||||
reply.content.push_back("\"mapped_coordinate\":[]");
|
reply.content.emplace_back("\"mapped_coordinate\":[]");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Write coordinate to stream
|
// Write coordinate to stream
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
reply.content.push_back("\"status\":0,");
|
reply.content.emplace_back("\"status\":0,");
|
||||||
reply.content.push_back("\"mapped_coordinate\":");
|
reply.content.emplace_back("\"mapped_coordinate\":");
|
||||||
FixedPointCoordinate::convertInternalLatLonToString(result.lat, tmp);
|
FixedPointCoordinate::convertInternalLatLonToString(result.lat, tmp);
|
||||||
reply.content.push_back("[");
|
reply.content.emplace_back("[");
|
||||||
reply.content.push_back(tmp);
|
reply.content.emplace_back(tmp);
|
||||||
FixedPointCoordinate::convertInternalLatLonToString(result.lon, tmp);
|
FixedPointCoordinate::convertInternalLatLonToString(result.lon, tmp);
|
||||||
reply.content.push_back(",");
|
reply.content.emplace_back(",");
|
||||||
reply.content.push_back(tmp);
|
reply.content.emplace_back(tmp);
|
||||||
reply.content.push_back("]");
|
reply.content.emplace_back("]");
|
||||||
}
|
}
|
||||||
reply.content.push_back("}");
|
reply.content.emplace_back("}");
|
||||||
reply.headers.resize(3);
|
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].name = "Content-Type";
|
||||||
reply.headers[1].value = "text/javascript";
|
reply.headers[1].value = "text/javascript";
|
||||||
reply.headers[2].name = "Content-Disposition";
|
reply.headers[2].name = "Content-Disposition";
|
||||||
|
@ -49,15 +49,15 @@ template <class DataFacadeT> class NearestPlugin : public BasePlugin
|
|||||||
|
|
||||||
const std::string GetDescriptor() const { return descriptor_string; }
|
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
|
// check number of parameters
|
||||||
if (routeParameters.coordinates.empty())
|
if (route_parameters.coordinates.empty())
|
||||||
{
|
{
|
||||||
reply = http::Reply::StockReply(http::Reply::badRequest);
|
reply = http::Reply::StockReply(http::Reply::badRequest);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!routeParameters.coordinates.front().isValid())
|
if (!route_parameters.coordinates.front().isValid())
|
||||||
{
|
{
|
||||||
reply = http::Reply::StockReply(http::Reply::badRequest);
|
reply = http::Reply::StockReply(http::Reply::badRequest);
|
||||||
return;
|
return;
|
||||||
@ -65,48 +65,48 @@ template <class DataFacadeT> class NearestPlugin : public BasePlugin
|
|||||||
|
|
||||||
PhantomNode result;
|
PhantomNode result;
|
||||||
facade->FindPhantomNodeForCoordinate(
|
facade->FindPhantomNodeForCoordinate(
|
||||||
routeParameters.coordinates.front(), result, routeParameters.zoomLevel);
|
route_parameters.coordinates.front(), result, route_parameters.zoom_level);
|
||||||
|
|
||||||
// json
|
// json
|
||||||
|
|
||||||
if (!routeParameters.jsonpParameter.empty())
|
if (!route_parameters.jsonp_parameter.empty())
|
||||||
{
|
{
|
||||||
reply.content.push_back(routeParameters.jsonpParameter);
|
reply.content.emplace_back(route_parameters.jsonp_parameter);
|
||||||
reply.content.push_back("(");
|
reply.content.emplace_back("(");
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
reply.content.push_back("{\"status\":");
|
reply.content.emplace_back("{\"status\":");
|
||||||
if (SPECIAL_NODEID != result.forward_node_id)
|
if (SPECIAL_NODEID != result.forward_node_id)
|
||||||
{
|
{
|
||||||
reply.content.push_back("0,");
|
reply.content.emplace_back("0,");
|
||||||
}
|
}
|
||||||
else
|
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;
|
std::string temp_string;
|
||||||
|
|
||||||
if (SPECIAL_NODEID != result.forward_node_id)
|
if (SPECIAL_NODEID != result.forward_node_id)
|
||||||
{
|
{
|
||||||
FixedPointCoordinate::convertInternalLatLonToString(result.location.lat, temp_string);
|
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);
|
FixedPointCoordinate::convertInternalLatLonToString(result.location.lon, temp_string);
|
||||||
reply.content.push_back(",");
|
reply.content.emplace_back(",");
|
||||||
reply.content.push_back(temp_string);
|
reply.content.emplace_back(temp_string);
|
||||||
}
|
}
|
||||||
reply.content.push_back("],\"name\":\"");
|
reply.content.emplace_back("],\"name\":\"");
|
||||||
if (SPECIAL_NODEID != result.forward_node_id)
|
if (SPECIAL_NODEID != result.forward_node_id)
|
||||||
{
|
{
|
||||||
facade->GetName(result.name_id, temp_string);
|
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);
|
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].name = "Content-Type";
|
||||||
reply.headers[1].value = "text/javascript";
|
reply.headers[1].value = "text/javascript";
|
||||||
reply.headers[2].name = "Content-Disposition";
|
reply.headers[2].name = "Content-Disposition";
|
||||||
|
@ -38,29 +38,29 @@ template <class DataFacadeT> class TimestampPlugin : public BasePlugin
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
const std::string GetDescriptor() const { return descriptor_string; }
|
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;
|
std::string tmp;
|
||||||
|
|
||||||
// json
|
// json
|
||||||
if (!routeParameters.jsonpParameter.empty())
|
if (!route_parameters.jsonp_parameter.empty())
|
||||||
{
|
{
|
||||||
reply.content.push_back(routeParameters.jsonpParameter);
|
reply.content.emplace_back(route_parameters.jsonp_parameter);
|
||||||
reply.content.push_back("(");
|
reply.content.emplace_back("(");
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
reply.content.push_back("{");
|
reply.content.emplace_back("{");
|
||||||
reply.content.push_back("\"status\":");
|
reply.content.emplace_back("\"status\":");
|
||||||
reply.content.push_back("0,");
|
reply.content.emplace_back("0,");
|
||||||
reply.content.push_back("\"timestamp\":\"");
|
reply.content.emplace_back("\"timestamp\":\"");
|
||||||
reply.content.push_back(facade->GetTimestamp());
|
reply.content.emplace_back(facade->GetTimestamp());
|
||||||
reply.content.push_back("\"");
|
reply.content.emplace_back("\"");
|
||||||
reply.content.push_back("}");
|
reply.content.emplace_back("}");
|
||||||
reply.headers.resize(3);
|
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].name = "Content-Type";
|
||||||
reply.headers[1].value = "text/javascript";
|
reply.headers[1].value = "text/javascript";
|
||||||
reply.headers[2].name = "Content-Disposition";
|
reply.headers[2].name = "Content-Disposition";
|
||||||
|
@ -108,7 +108,7 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
|
|||||||
}
|
}
|
||||||
facade->FindPhantomNodeForCoordinate(raw_route.raw_via_node_coordinates[i],
|
facade->FindPhantomNodeForCoordinate(raw_route.raw_via_node_coordinates[i],
|
||||||
phantom_node_vector[i],
|
phantom_node_vector[i],
|
||||||
routeParameters.zoomLevel);
|
routeParameters.zoom_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
PhantomNodes current_phantom_node_pair;
|
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);
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -134,19 +135,19 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
|
|||||||
}
|
}
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
|
|
||||||
if (!routeParameters.jsonpParameter.empty())
|
if (!routeParameters.jsonp_parameter.empty())
|
||||||
{
|
{
|
||||||
reply.content.push_back(routeParameters.jsonpParameter);
|
reply.content.emplace_back(routeParameters.jsonp_parameter);
|
||||||
reply.content.push_back("(");
|
reply.content.emplace_back("(");
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptorConfig descriptor_config;
|
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);
|
unsigned descriptor_type = (iter != descriptorTable.end() ? iter->second : 0);
|
||||||
|
|
||||||
descriptor_config.zoom_level = routeParameters.zoomLevel;
|
descriptor_config.zoom_level = routeParameters.zoom_level;
|
||||||
descriptor_config.instructions = routeParameters.printInstructions;
|
descriptor_config.instructions = routeParameters.print_instructions;
|
||||||
descriptor_config.geometry = routeParameters.geometry;
|
descriptor_config.geometry = routeParameters.geometry;
|
||||||
descriptor_config.encode_geometry = routeParameters.compression;
|
descriptor_config.encode_geometry = routeParameters.compression;
|
||||||
|
|
||||||
@ -170,9 +171,9 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
|
|||||||
descriptor->SetConfig(descriptor_config);
|
descriptor->SetConfig(descriptor_config);
|
||||||
descriptor->Run(raw_route, phantom_nodes, facade, reply);
|
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.resize(3);
|
||||||
reply.headers[0].name = "Content-Length";
|
reply.headers[0].name = "Content-Length";
|
||||||
@ -189,7 +190,7 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
|
|||||||
switch (descriptor_type)
|
switch (descriptor_type)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (!routeParameters.jsonpParameter.empty())
|
if (!routeParameters.jsonp_parameter.empty())
|
||||||
{
|
{
|
||||||
reply.headers[1].name = "Content-Type";
|
reply.headers[1].name = "Content-Type";
|
||||||
reply.headers[1].value = "text/javascript";
|
reply.headers[1].value = "text/javascript";
|
||||||
@ -213,7 +214,7 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!routeParameters.jsonpParameter.empty())
|
if (!routeParameters.jsonp_parameter.empty())
|
||||||
{
|
{
|
||||||
reply.headers[1].name = "Content-Type";
|
reply.headers[1].name = "Content-Type";
|
||||||
reply.headers[1].value = "text/javascript";
|
reply.headers[1].value = "text/javascript";
|
||||||
|
@ -86,15 +86,15 @@ int main (int argc, const char * argv[]) {
|
|||||||
OSRM routing_machine( server_paths, use_shared_memory );
|
OSRM routing_machine( server_paths, use_shared_memory );
|
||||||
|
|
||||||
RouteParameters route_parameters;
|
RouteParameters route_parameters;
|
||||||
route_parameters.zoomLevel = 18; //no generalization
|
route_parameters.zoom_level = 18; //no generalization
|
||||||
route_parameters.printInstructions = true; //turn by turn instructions
|
route_parameters.print_instructions = true; //turn by turn instructions
|
||||||
route_parameters.alternateRoute = true; //get an alternate route, too
|
route_parameters.alternate_route = true; //get an alternate route, too
|
||||||
route_parameters.geometry = true; //retrieve geometry of route
|
route_parameters.geometry = true; //retrieve geometry of route
|
||||||
route_parameters.compression = true; //polyline encoding
|
route_parameters.compression = true; //polyline encoding
|
||||||
route_parameters.check_sum = UINT_MAX; //see wiki
|
route_parameters.check_sum = UINT_MAX; //see wiki
|
||||||
route_parameters.service = "viaroute"; //that's routing
|
route_parameters.service = "viaroute"; //that's routing
|
||||||
route_parameters.outputFormat = "json";
|
route_parameters.output_format = "json";
|
||||||
route_parameters.jsonpParameter = ""; //set for jsonp wrapping
|
route_parameters.jsonp_parameter = ""; //set for jsonp wrapping
|
||||||
route_parameters.language = ""; //unused atm
|
route_parameters.language = ""; //unused atm
|
||||||
//route_parameters.hints.push_back(); // see wiki, saves I/O if done properly
|
//route_parameters.hints.push_back(); // see wiki, saves I/O if done properly
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user