remove an unneeded parameter

This commit is contained in:
Dennis Luxen 2014-05-26 15:31:30 +02:00
parent 37f8285a6e
commit 0325861ef3
5 changed files with 29 additions and 14 deletions

View File

@ -54,9 +54,7 @@ template <class DataFacadeT> class BaseDescriptor
BaseDescriptor() {}
// Maybe someone can explain the pure virtual destructor thing to me (dennis)
virtual ~BaseDescriptor() {}
virtual void Run(const RawRouteData &raw_route,
const PhantomNodes &phantom_nodes,
http::Reply &reply) = 0;
virtual void Run(const RawRouteData &raw_route, http::Reply &reply) = 0;
virtual void SetConfig(const DescriptorConfig &config) = 0;
};

View File

@ -27,7 +27,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "DescriptionFactory.h"
DescriptionFactory::DescriptionFactory() : entireLength(0) {}
DescriptionFactory::DescriptionFactory() : entireLength(0)
{
via_indices.push_back(0);
}
std::vector<unsigned> const & DescriptionFactory::GetViaIndices() const
{
return via_indices;
}
void DescriptionFactory::SetStartSegment(const PhantomNode &source)
{
@ -39,7 +48,7 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target)
{
target_phantom = target;
path_description.emplace_back(
target.location, target.name_id, 0, target.reverse_weight, TurnInstruction::NoTurn, true);
target.location, target.name_id, 0, target.reverse_weight, TurnInstruction::NoTurn, true, true);
}
void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate,

View File

@ -54,6 +54,8 @@ class DescriptionFactory
double DegreeToRadian(const double degree) const;
double RadianToDegree(const double degree) const;
std::vector<unsigned> via_indices;
public:
struct RouteSummary
{
@ -82,6 +84,7 @@ class DescriptionFactory
void SetStartSegment(const PhantomNode &start_phantom);
void SetEndSegment(const PhantomNode &start_phantom);
JSON::Value AppendEncodedPolylineString(const bool return_encoded);
std::vector<unsigned> const & GetViaIndices() const;
template <class DataFacadeT> void Run(const DataFacadeT *facade, const unsigned zoomLevel)
{
@ -190,14 +193,24 @@ class DescriptionFactory
polyline_generalizer.Run(path_description, zoomLevel);
// fix what needs to be fixed else
unsigned necessary_pieces = 0;
for (unsigned i = 0; i < path_description.size() - 1 && path_description.size() >= 2; ++i)
{
if (path_description[i].necessary)
{
if (path_description[i].is_via_location)
{
via_indices.push_back(necessary_pieces);
}
const double angle = path_description[i+1].location.GetBearing(path_description[i].location);
path_description[i].bearing = angle * 10;
++necessary_pieces;
}
}
via_indices.push_back(necessary_pieces);
BOOST_ASSERT(via_indices.size() >= 2);
BOOST_ASSERT(0 != necessary_pieces);
return;
}
};

View File

@ -62,9 +62,7 @@ template <class DataFacadeT> class GPXDescriptor : public BaseDescriptor<DataFac
void SetConfig(const DescriptorConfig &c) { config = c; }
// TODO: reorder parameters
void Run(const RawRouteData &raw_route,
const PhantomNodes &phantom_node_list,
http::Reply &reply)
void Run(const RawRouteData &raw_route, http::Reply &reply)
{
std::string header("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<gpx creator=\"OSRM Routing Engine\" version=\"1.1\" "
@ -81,7 +79,7 @@ template <class DataFacadeT> class GPXDescriptor : public BaseDescriptor<DataFac
(!raw_route.unpacked_path_segments.front().empty());
if (found_route)
{
AddRoutePoint(phantom_node_list.source_phantom.location, reply.content);
AddRoutePoint(raw_route.segment_end_coordinates.front().source_phantom.location, reply.content);
for (const std::vector<PathData> &path_data_vector : raw_route.unpacked_path_segments)
{
@ -92,7 +90,7 @@ template <class DataFacadeT> class GPXDescriptor : public BaseDescriptor<DataFac
AddRoutePoint(current_coordinate, reply.content);
}
}
AddRoutePoint(phantom_node_list.target_phantom.location, reply.content);
AddRoutePoint(raw_route.segment_end_coordinates.back().target_phantom.location, reply.content);
}
std::string footer("</rte></gpx>");

View File

@ -161,11 +161,8 @@ template <class DataFacadeT> class ViaRoutePlugin : public BasePlugin
break;
}
PhantomNodes phantom_nodes;
phantom_nodes.source_phantom = raw_route.segment_end_coordinates.front().source_phantom;
phantom_nodes.target_phantom = raw_route.segment_end_coordinates.back().target_phantom;
descriptor->SetConfig(descriptor_config);
descriptor->Run(raw_route, phantom_nodes, reply);
descriptor->Run(raw_route, reply);
}
private: