2011-01-09 16:42:27 -05:00
|
|
|
/*
|
2013-10-14 07:42:28 -04:00
|
|
|
|
|
|
|
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
Redistributions of source code must retain the above copyright notice, this list
|
|
|
|
of conditions and the following disclaimer.
|
|
|
|
Redistributions in binary form must reproduce the above copyright notice, this
|
|
|
|
list of conditions and the following disclaimer in the documentation and/or
|
|
|
|
other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
2011-01-09 16:42:27 -05:00
|
|
|
|
|
|
|
#ifndef HELLOWORLDPLUGIN_H_
|
|
|
|
#define HELLOWORLDPLUGIN_H_
|
|
|
|
|
|
|
|
#include "BasePlugin.h"
|
2013-11-14 17:16:26 -05:00
|
|
|
#include "../Util/StringUtil.h"
|
2011-01-09 16:42:27 -05:00
|
|
|
|
2013-11-14 17:16:26 -05:00
|
|
|
#include <string>
|
2013-06-26 19:48:02 -04:00
|
|
|
|
2014-05-02 12:06:31 -04:00
|
|
|
class HelloWorldPlugin : public BasePlugin
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::string temp_string;
|
|
|
|
|
|
|
|
public:
|
|
|
|
HelloWorldPlugin() : descriptor_string("hello") {}
|
|
|
|
virtual ~HelloWorldPlugin() {}
|
|
|
|
const std::string GetDescriptor() const { return descriptor_string; }
|
|
|
|
|
|
|
|
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>");
|
2013-11-14 17:16:26 -05:00
|
|
|
reply.content.push_back("zoom level: ");
|
|
|
|
intToString(routeParameters.zoomLevel, temp_string);
|
|
|
|
reply.content.push_back(temp_string);
|
|
|
|
reply.content.push_back("\nchecksum: ");
|
2014-05-07 12:39:16 -04:00
|
|
|
intToString(routeParameters.check_sum, temp_string);
|
2013-11-14 17:16:26 -05:00
|
|
|
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: ");
|
|
|
|
intToString(routeParameters.coordinates.size(), temp_string);
|
|
|
|
reply.content.push_back(temp_string);
|
|
|
|
reply.content.push_back("\n");
|
2014-05-02 12:06:31 -04:00
|
|
|
|
|
|
|
unsigned counter = 0;
|
|
|
|
for (const FixedPointCoordinate &coordinate : routeParameters.coordinates)
|
|
|
|
{
|
|
|
|
reply.content.push_back(" [");
|
|
|
|
intToString(counter, temp_string);
|
2013-11-14 17:16:26 -05:00
|
|
|
reply.content.push_back(temp_string);
|
|
|
|
reply.content.push_back("] ");
|
2014-05-02 12:06:31 -04:00
|
|
|
doubleToString(coordinate.lat / COORDINATE_PRECISION, temp_string);
|
2013-11-14 17:16:26 -05:00
|
|
|
reply.content.push_back(temp_string);
|
|
|
|
reply.content.push_back(",");
|
2014-05-02 12:06:31 -04:00
|
|
|
doubleToString(coordinate.lon / COORDINATE_PRECISION, temp_string);
|
2013-11-14 17:16:26 -05:00
|
|
|
reply.content.push_back(temp_string);
|
|
|
|
reply.content.push_back("\n");
|
2014-05-02 12:06:31 -04:00
|
|
|
++counter;
|
2012-09-12 09:01:37 -04:00
|
|
|
}
|
2014-05-02 12:06:31 -04:00
|
|
|
|
|
|
|
reply.content.push_back("Number of hints: ");
|
2013-11-14 17:16:26 -05:00
|
|
|
intToString(routeParameters.hints.size(), temp_string);
|
|
|
|
reply.content.push_back(temp_string);
|
|
|
|
reply.content.push_back("\n");
|
2014-05-02 12:06:31 -04:00
|
|
|
|
|
|
|
counter = 0;
|
|
|
|
for (const std::string ¤t_string : routeParameters.hints)
|
|
|
|
{
|
|
|
|
reply.content.push_back(" [");
|
|
|
|
intToString(counter, temp_string);
|
2013-11-14 17:16:26 -05:00
|
|
|
reply.content.push_back(temp_string);
|
|
|
|
reply.content.push_back("] ");
|
2014-05-02 12:06:31 -04:00
|
|
|
reply.content.push_back(current_string);
|
2013-11-14 17:16:26 -05:00
|
|
|
reply.content.push_back("\n");
|
2014-05-02 12:06:31 -04:00
|
|
|
++counter;
|
2012-09-12 09:01:37 -04:00
|
|
|
}
|
2014-05-02 12:06:31 -04:00
|
|
|
reply.content.push_back("</pre></body></html>");
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2013-08-13 12:09:20 -04:00
|
|
|
std::string descriptor_string;
|
2011-01-09 16:42:27 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* HELLOWORLDPLUGIN_H_ */
|