implements output generation through a dedicated JSON container:

- JSON syntax is not scattered over several files, but one place
- Reduces code duplication
- breaking changes:
  - new property in json(p) formatted response: "found_alternative": True/False
  - returned filenames now response.js(on) or route.gpx
  - /hello plugin returns JSON now
This commit is contained in:
Dennis Luxen
2014-05-16 16:09:40 +02:00
parent acab77f4f8
commit a80815d57a
28 changed files with 1092 additions and 675 deletions
+153
View File
@@ -0,0 +1,153 @@
/*
Copyright (c) 2014, 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.
*/
#ifndef DISTANCE_TABLE_PLUGIN_H
#define DISTANCE_TABLE_PLUGIN_H
#include "BasePlugin.h"
#include "../Algorithms/ObjectToBase64.h"
#include "../DataStructures/JSONContainer.h"
#include "../DataStructures/QueryEdge.h"
#include "../DataStructures/SearchEngine.h"
#include "../Descriptors/BaseDescriptor.h"
#include "../Descriptors/GPXDescriptor.h"
#include "../Descriptors/JSONDescriptor.h"
#include "../Util/SimpleLogger.h"
#include "../Util/StringUtil.h"
#include "../Util/TimingUtil.h"
#include <cstdlib>
#include <algorithm>
#include <memory>
#include <unordered_map>
#include <string>
#include <vector>
template <class DataFacadeT> class DistanceTablePlugin : public BasePlugin
{
private:
std::shared_ptr<SearchEngine<DataFacadeT>> search_engine_ptr;
public:
explicit DistanceTablePlugin(DataFacadeT *facade) : descriptor_string("table"), facade(facade)
{
search_engine_ptr = std::make_shared<SearchEngine<DataFacadeT>>(facade);
}
virtual ~DistanceTablePlugin() {}
const std::string GetDescriptor() const { return descriptor_string; }
void HandleRequest(const RouteParameters &route_parameters, http::Reply &reply)
{
SimpleLogger().Write() << "running DT plugin";
// check number of parameters
if (2 > route_parameters.coordinates.size())
{
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
}
RawRouteData raw_route;
raw_route.check_sum = facade->GetCheckSum();
if (std::any_of(begin(route_parameters.coordinates),
end(route_parameters.coordinates),
[&](FixedPointCoordinate coordinate)
{ return !coordinate.isValid(); }))
{
SimpleLogger().Write() << "invalid coordinate";
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
}
for (const FixedPointCoordinate &coordinate : route_parameters.coordinates)
{
raw_route.raw_via_node_coordinates.emplace_back(coordinate);
SimpleLogger().Write() << "adding coordinate " << coordinate;
}
std::vector<PhantomNode> phantom_node_vector(raw_route.raw_via_node_coordinates.size());
const bool checksum_OK = (route_parameters.check_sum == raw_route.check_sum);
unsigned max_locations = std::min(25, max_locations);
for (unsigned i = 0; i < max_locations; ++i)
{
if (checksum_OK && i < route_parameters.hints.size() &&
!route_parameters.hints[i].empty())
{
DecodeObjectFromBase64(route_parameters.hints[i], phantom_node_vector[i]);
if (phantom_node_vector[i].isValid(facade->GetNumberOfNodes()))
{
SimpleLogger().Write() << "decoded phantom node for " << phantom_node_vector[i].location;
continue;
}
}
SimpleLogger().Write() << "looking up coordinate in tree";
facade->FindPhantomNodeForCoordinate(raw_route.raw_via_node_coordinates[i],
phantom_node_vector[i],
route_parameters.zoom_level);
BOOST_ASSERT(phantom_node_vector[i].isValid(facade->GetNumberOfNodes()));
}
TIMER_START(distance_table);
std::shared_ptr<std::vector<EdgeWeight>> result_table = search_engine_ptr->distance_table(phantom_node_vector);
TIMER_STOP(distance_table);
SimpleLogger().Write() << "table computation took " << TIMER_MSEC(distance_table) << "ms";
if (!result_table)
{
SimpleLogger().Write() << "computation failed";
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
}
SimpleLogger().Write() << "computation successful";
JSON::Object json_object;
JSON::Array json_array;
const unsigned number_of_locations = phantom_node_vector.size();
for(unsigned row = 0; row < number_of_locations; ++row)
{
JSON::Array json_row;
auto row_begin_iterator = result_table->begin() + (row*number_of_locations);
auto row_end_iterator = result_table->begin() + ((row+1)*number_of_locations);
json_row.values.insert(json_row.values.end(), row_begin_iterator, row_end_iterator);
json_array.values.push_back(json_row);
}
json_object.values["distance_table"] = json_array;
JSON::render(reply.content, json_object);
}
private:
std::string descriptor_string;
DataFacadeT *facade;
};
#endif // DISTANCE_TABLE_PLUGIN_H
+41 -52
View File
@@ -25,10 +25,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef HELLOWORLDPLUGIN_H_
#define HELLOWORLDPLUGIN_H_
#ifndef HELLO_WORLD_PLUGIN_H
#define HELLO_WORLD_PLUGIN_H
#include "BasePlugin.h"
#include "../DataStructures/JSONContainer.h"
#include "../Util/StringUtil.h"
#include <string>
@@ -46,70 +47,58 @@ class HelloWorldPlugin : public BasePlugin
void HandleRequest(const RouteParameters &routeParameters, http::Reply &reply)
{
reply.status = http::Reply::ok;
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.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.emplace_back(temp_string);
reply.content.emplace_back("\n");
JSON::Object json_result;
std::string temp_string;
json_result.values["title"] = "Hello World";
temp_string = IntToString(routeParameters.zoom_level);
json_result.values["zoom_level"] = temp_string;
temp_string = IntToString(routeParameters.check_sum);
json_result.values["check_sum"] = temp_string;
json_result.values["instructions"] = (routeParameters.print_instructions ? "yes" : "no");
json_result.values["geometry"] = (routeParameters.geometry ? "yes" : "no");
json_result.values["compression"] = (routeParameters.compression ? "yes" : "no");
json_result.values["output_format"] = (!routeParameters.output_format.empty() ? "yes" : "no");
json_result.values["jsonp_parameter"] = (!routeParameters.jsonp_parameter.empty() ? "yes" : "no");
json_result.values["language"] = (!routeParameters.language.empty() ? "yes" : "no");
temp_string = IntToString(routeParameters.coordinates.size());
json_result.values["location_count"] = temp_string;
JSON::Array json_locations;
unsigned counter = 0;
for (const FixedPointCoordinate &coordinate : routeParameters.coordinates)
{
reply.content.emplace_back(" [");
intToString(counter, temp_string);
reply.content.emplace_back(temp_string);
reply.content.emplace_back("] ");
doubleToString(coordinate.lat / COORDINATE_PRECISION, temp_string);
reply.content.emplace_back(temp_string);
reply.content.emplace_back(",");
doubleToString(coordinate.lon / COORDINATE_PRECISION, temp_string);
reply.content.emplace_back(temp_string);
reply.content.emplace_back("\n");
JSON::Object json_location;
JSON::Array json_coordinates;
json_coordinates.values.push_back(coordinate.lat / COORDINATE_PRECISION);
json_coordinates.values.push_back(coordinate.lon / COORDINATE_PRECISION);
json_location.values[IntToString(counter)] = json_coordinates;
json_locations.values.push_back(json_location);
++counter;
}
json_result.values["locations"] = json_locations;
json_result.values["hint_count"] = routeParameters.hints.size();
reply.content.emplace_back("Number of hints: ");
intToString(routeParameters.hints.size(), temp_string);
reply.content.emplace_back(temp_string);
reply.content.emplace_back("\n");
JSON::Array json_hints;
counter = 0;
for (const std::string &current_string : routeParameters.hints)
for (const std::string &current_hint : routeParameters.hints)
{
reply.content.emplace_back(" [");
intToString(counter, temp_string);
reply.content.emplace_back(temp_string);
reply.content.emplace_back("] ");
reply.content.emplace_back(current_string);
reply.content.emplace_back("\n");
// JSON::String json_hint_string = current_hint;
json_hints.values.push_back(current_hint);
++counter;
}
reply.content.emplace_back("</pre></body></html>");
json_result.values["hints"] = json_hints;
JSON::render(reply.content, json_result);
}
private:
std::string descriptor_string;
};
#endif /* HELLOWORLDPLUGIN_H_ */
#endif // HELLO_WORLD_PLUGIN_H
+19 -51
View File
@@ -29,10 +29,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define LOCATE_PLUGIN_H
#include "BasePlugin.h"
#include "../DataStructures/JSONContainer.h"
#include "../Util/StringUtil.h"
// locates the nearest node in the road network for a given coordinate.
#include <string>
// locates the nearest node in the road network for a given coordinate.
template <class DataFacadeT> class LocatePlugin : public BasePlugin
{
public:
@@ -42,70 +44,36 @@ template <class DataFacadeT> class LocatePlugin : public BasePlugin
void HandleRequest(const RouteParameters &route_parameters, http::Reply &reply)
{
// check number of parameters
if (route_parameters.coordinates.empty() || !route_parameters.coordinates.front().isValid())
if (route_parameters.coordinates.empty())
{
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
}
// check if queried location is sane
if (!route_parameters.coordinates.front().isValid())
{
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
}
// query to helpdesk
JSON::Object json_result;
FixedPointCoordinate result;
std::string tmp;
// json
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.emplace_back(route_parameters.jsonp_parameter);
reply.content.emplace_back("(");
}
reply.status = http::Reply::ok;
reply.content.emplace_back("{");
if (!facade->LocateClosestEndPointForCoordinate(route_parameters.coordinates.front(),
result))
{
reply.content.emplace_back("\"status\":207,");
reply.content.emplace_back("\"mapped_coordinate\":[]");
json_result.values["status"] = 207;
}
else
{
// Write coordinate to stream
reply.status = http::Reply::ok;
reply.content.emplace_back("\"status\":0,");
reply.content.emplace_back("\"mapped_coordinate\":");
FixedPointCoordinate::convertInternalLatLonToString(result.lat, tmp);
reply.content.emplace_back("[");
reply.content.emplace_back(tmp);
FixedPointCoordinate::convertInternalLatLonToString(result.lon, tmp);
reply.content.emplace_back(",");
reply.content.emplace_back(tmp);
reply.content.emplace_back("]");
json_result.values["status"] = 0;
JSON::Array json_coordinate;
json_coordinate.values.push_back(result.lat/COORDINATE_PRECISION);
json_coordinate.values.push_back(result.lon/COORDINATE_PRECISION);
json_result.values["mapped_coordinate"] = json_coordinate;
}
reply.content.emplace_back("}");
reply.headers.resize(3);
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.emplace_back(")");
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "text/javascript";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"location.js\"";
}
else
{
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "application/x-javascript";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"location.json\"";
}
reply.headers[0].name = "Content-Length";
unsigned content_length = 0;
for (const std::string &snippet : reply.content)
{
content_length += snippet.length();
}
intToString(content_length, tmp);
reply.headers[0].value = tmp;
return;
JSON::render(reply.content, json_result);
}
private:
+18 -60
View File
@@ -29,10 +29,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define NEAREST_PLUGIN_H
#include "BasePlugin.h"
#include "../DataStructures/JSONContainer.h"
#include "../DataStructures/PhantomNodes.h"
#include "../Util/StringUtil.h"
#include <unordered_map>
#include <string>
/*
* This Plugin locates the nearest point on a street in the road network for a given coordinate.
@@ -43,8 +44,6 @@ template <class DataFacadeT> class NearestPlugin : public BasePlugin
public:
explicit NearestPlugin(DataFacadeT *facade) : facade(facade), descriptor_string("nearest")
{
descriptor_table.emplace("", 0); // default descriptor
descriptor_table.emplace("json", 1);
}
const std::string GetDescriptor() const { return descriptor_string; }
@@ -57,81 +56,40 @@ template <class DataFacadeT> class NearestPlugin : public BasePlugin
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
}
// check if queried location is sane
if (!route_parameters.coordinates.front().isValid())
{
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
}
PhantomNode result;
PhantomNode phantom_node;
facade->FindPhantomNodeForCoordinate(
route_parameters.coordinates.front(), result, route_parameters.zoom_level);
route_parameters.coordinates.front(), phantom_node, route_parameters.zoom_level);
// json
if (!route_parameters.jsonp_parameter.empty())
JSON::Object json_result;
if (!phantom_node.isValid())
{
reply.content.emplace_back(route_parameters.jsonp_parameter);
reply.content.emplace_back("(");
}
reply.status = http::Reply::ok;
reply.content.emplace_back("{\"status\":");
if (SPECIAL_NODEID != result.forward_node_id)
{
reply.content.emplace_back("0,");
json_result.values["status"] = 207;
}
else
{
reply.content.emplace_back("207,");
reply.status = http::Reply::ok;
json_result.values["status"] = 0;
JSON::Array json_coordinate;
json_coordinate.values.push_back(phantom_node.location.lat/COORDINATE_PRECISION);
json_coordinate.values.push_back(phantom_node.location.lon/COORDINATE_PRECISION);
json_result.values["mapped_coordinate"] = json_coordinate;
std::string temp_string;
facade->GetName(phantom_node.name_id, temp_string);
json_result.values["name"] = temp_string;
}
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.emplace_back(temp_string);
FixedPointCoordinate::convertInternalLatLonToString(result.location.lon, temp_string);
reply.content.emplace_back(",");
reply.content.emplace_back(temp_string);
}
reply.content.emplace_back("],\"name\":\"");
if (SPECIAL_NODEID != result.forward_node_id)
{
facade->GetName(result.name_id, temp_string);
reply.content.emplace_back(temp_string);
}
reply.content.emplace_back("\"}");
reply.headers.resize(3);
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.emplace_back(")");
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "text/javascript";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"location.js\"";
}
else
{
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "application/x-javascript";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"location.json\"";
}
reply.headers[0].name = "Content-Length";
unsigned content_length = 0;
for (const std::string &snippet : reply.content)
{
content_length += snippet.length();
}
intToString(content_length, temp_string);
reply.headers[0].value = temp_string;
JSON::render(reply.content, json_result);
}
private:
DataFacadeT *facade;
std::unordered_map<std::string, unsigned> descriptor_table;
std::string descriptor_string;
};
+8 -39
View File
@@ -28,8 +28,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef TIMESTAMP_PLUGIN_H
#define TIMESTAMP_PLUGIN_H
#include "../DataStructures/JSONContainer.h"
#include "BasePlugin.h"
#include <string>
template <class DataFacadeT> class TimestampPlugin : public BasePlugin
{
public:
@@ -40,46 +43,12 @@ template <class DataFacadeT> class TimestampPlugin : public BasePlugin
const std::string GetDescriptor() const { return descriptor_string; }
void HandleRequest(const RouteParameters &route_parameters, http::Reply &reply)
{
std::string tmp;
// json
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.emplace_back(route_parameters.jsonp_parameter);
reply.content.emplace_back("(");
}
reply.status = http::Reply::ok;
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 (!route_parameters.jsonp_parameter.empty())
{
reply.content.emplace_back(")");
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "text/javascript";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"timestamp.js\"";
}
else
{
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "application/x-javascript";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"timestamp.json\"";
}
unsigned content_length = 0;
for (const std::string &snippet : reply.content)
{
content_length += snippet.length();
}
intToString(content_length, tmp);
reply.headers[0].value = tmp;
JSON::Object json_result;
json_result.values["status"] = 0;
const std::string timestamp = facade->GetTimestamp();
json_result.values["timestamp"] = timestamp;
JSON::render(reply.content, json_result);
}
private:
+11 -71
View File
@@ -25,12 +25,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef VIAROUTEPLUGIN_H_
#define VIAROUTEPLUGIN_H_
#ifndef VIA_ROUTE_PLUGIN_H
#define VIA_ROUTE_PLUGIN_H
#include "BasePlugin.h"
#include "../Algorithms/ObjectToBase64.h"
#include "../DataStructures/QueryEdge.h"
#include "../DataStructures/SearchEngine.h"
#include "../Descriptors/BaseDescriptor.h"
@@ -60,6 +61,7 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
descriptor_table.emplace("json", 0);
descriptor_table.emplace("gpx", 1);
// descriptor_table.emplace("geojson", 2);
}
virtual ~ViaRoutePlugin() {}
@@ -119,7 +121,9 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
raw_route.segment_end_coordinates.emplace_back(current_phantom_node_pair);
}
if ((route_parameters.alternate_route) && (1 == raw_route.segment_end_coordinates.size()))
const bool is_alternate_requested = route_parameters.alternate_route;
const bool is_only_one_segment = (1 == raw_route.segment_end_coordinates.size());
if (is_alternate_requested && is_only_one_segment)
{
search_engine_ptr->alternative_path(raw_route.segment_end_coordinates.front(),
raw_route);
@@ -135,12 +139,6 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
}
reply.status = http::Reply::ok;
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.emplace_back(route_parameters.jsonp_parameter);
reply.content.emplace_back("(");
}
DescriptorConfig descriptor_config;
auto iter = descriptor_table.find(route_parameters.output_format);
@@ -160,6 +158,9 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
case 1:
descriptor = std::make_shared<GPXDescriptor<DataFacadeT>>();
break;
// case 2:
// descriptor = std::make_shared<GEOJSONDescriptor<DataFacadeT>>();
// break;
default:
descriptor = std::make_shared<JSONDescriptor<DataFacadeT>>();
break;
@@ -170,67 +171,6 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
phantom_nodes.target_phantom = raw_route.segment_end_coordinates.back().target_phantom;
descriptor->SetConfig(descriptor_config);
descriptor->Run(raw_route, phantom_nodes, facade, reply);
if (!route_parameters.jsonp_parameter.empty())
{
reply.content.emplace_back(")\n");
}
reply.headers.resize(3);
reply.headers[0].name = "Content-Length";
unsigned content_length = 0;
for (const std::string &snippet : reply.content)
{
content_length += snippet.length();
}
std::string tmp_string;
intToString(content_length, tmp_string);
reply.headers[0].value = tmp_string;
switch (descriptor_type)
{
case 0:
if (!route_parameters.jsonp_parameter.empty())
{
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "text/javascript";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"route.js\"";
}
else
{
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "application/x-javascript";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"route.json\"";
}
break;
case 1:
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "application/gpx+xml; charset=UTF-8";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"route.gpx\"";
break;
default:
if (!route_parameters.jsonp_parameter.empty())
{
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "text/javascript";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"route.js\"";
}
else
{
reply.headers[1].name = "Content-Type";
reply.headers[1].value = "application/x-javascript";
reply.headers[2].name = "Content-Disposition";
reply.headers[2].value = "attachment; filename=\"route.json\"";
}
break;
}
return;
}
private:
@@ -238,4 +178,4 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
DataFacadeT *facade;
};
#endif /* VIAROUTEPLUGIN_H_ */
#endif // VIA_ROUTE_PLUGIN_H