2011-01-09 16:42:27 -05:00
|
|
|
/*
|
2013-08-13 12:09:20 -04:00
|
|
|
open source routing machine
|
|
|
|
Copyright (C) Dennis Luxen, 2010
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU AFFERO General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
or see http://www.gnu.org/licenses/agpl.txt.
|
2011-01-09 16:42:27 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HELLOWORLDPLUGIN_H_
|
|
|
|
#define HELLOWORLDPLUGIN_H_
|
|
|
|
|
|
|
|
#include "BasePlugin.h"
|
|
|
|
|
2013-06-26 19:48:02 -04:00
|
|
|
#include <sstream>
|
|
|
|
|
2011-01-09 16:42:27 -05:00
|
|
|
class HelloWorldPlugin : public BasePlugin {
|
|
|
|
public:
|
2013-08-13 12:09:20 -04:00
|
|
|
HelloWorldPlugin() : descriptor_string("hello"){}
|
2013-06-26 19:48:02 -04:00
|
|
|
virtual ~HelloWorldPlugin() { }
|
2013-08-13 12:09:20 -04:00
|
|
|
const std::string & GetDescriptor() const { return descriptor_string; }
|
2011-12-30 06:20:36 -05:00
|
|
|
|
2011-12-28 08:14:09 -05:00
|
|
|
void HandleRequest(const RouteParameters & routeParameters, http::Reply& reply) {
|
2011-01-09 16:42:27 -05:00
|
|
|
reply.status = http::Reply::ok;
|
|
|
|
reply.content.append("<html><head><title>Hello World Demonstration Document</title></head><body><h1>Hello, World!</h1>");
|
|
|
|
std::stringstream content;
|
2012-09-12 09:15:21 -04:00
|
|
|
content << "<pre>";
|
|
|
|
content << "zoom level: " << routeParameters.zoomLevel << "\n";
|
|
|
|
content << "checksum: " << routeParameters.checkSum << "\n";
|
|
|
|
content << "instructions: " << (routeParameters.printInstructions ? "yes" : "no") << "\n";
|
|
|
|
content << "geometry: " << (routeParameters.geometry ? "yes" : "no") << "\n";
|
|
|
|
content << "compression: " << (routeParameters.compression ? "yes" : "no") << "\n";
|
|
|
|
content << "output format: " << routeParameters.outputFormat << "\n";
|
|
|
|
content << "json parameter: " << routeParameters.jsonpParameter << "\n";
|
|
|
|
content << "language: " << routeParameters.language << "<br>";
|
|
|
|
content << "Number of locations: " << routeParameters.coordinates.size() << "\n";
|
2012-09-12 09:01:37 -04:00
|
|
|
for(unsigned i = 0; i < routeParameters.coordinates.size(); ++i) {
|
2013-08-05 12:37:42 -04:00
|
|
|
content << " [" << i << "] " << routeParameters.coordinates[i].lat/COORDINATE_PRECISION << "," << routeParameters.coordinates[i].lon/COORDINATE_PRECISION << "\n";
|
2012-09-12 09:01:37 -04:00
|
|
|
}
|
2012-09-12 09:15:21 -04:00
|
|
|
content << "Number of hints: " << routeParameters.hints.size() << "\n";
|
2012-09-12 09:01:37 -04:00
|
|
|
for(unsigned i = 0; i < routeParameters.hints.size(); ++i) {
|
2012-09-12 09:15:21 -04:00
|
|
|
content << " [" << i << "] " << routeParameters.hints[i] << "\n";
|
2012-09-12 09:01:37 -04:00
|
|
|
}
|
2012-09-12 09:15:21 -04:00
|
|
|
content << "</pre>";
|
2011-01-09 16:42:27 -05:00
|
|
|
reply.content.append(content.str());
|
|
|
|
reply.content.append("</body></html>");
|
|
|
|
}
|
2013-08-13 12:09:20 -04:00
|
|
|
private:
|
|
|
|
std::string descriptor_string;
|
2011-01-09 16:42:27 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* HELLOWORLDPLUGIN_H_ */
|