Refactoring base descriptor class
This commit is contained in:
parent
27b6627110
commit
12b4fff81e
@ -37,11 +37,16 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#include <vector>
|
||||
|
||||
struct DescriptorConfig {
|
||||
DescriptorConfig() : instructions(true), geometry(true), encodeGeometry(true), z(18) {}
|
||||
DescriptorConfig() :
|
||||
instructions(true),
|
||||
geometry(true),
|
||||
encode_geometry(true),
|
||||
zoom_level(18)
|
||||
{ }
|
||||
bool instructions;
|
||||
bool geometry;
|
||||
bool encodeGeometry;
|
||||
unsigned short z;
|
||||
bool encode_geometry;
|
||||
unsigned short zoom_level;
|
||||
};
|
||||
|
||||
template<class DataFacadeT>
|
||||
@ -50,7 +55,12 @@ public:
|
||||
BaseDescriptor() { }
|
||||
//Maybe someone can explain the pure virtual destructor thing to me (dennis)
|
||||
virtual ~BaseDescriptor() { }
|
||||
virtual void Run(http::Reply & reply, const RawRouteData &rawRoute, PhantomNodes &phantomNodes, const DataFacadeT * facade) = 0;
|
||||
virtual void Run(
|
||||
http::Reply & reply,
|
||||
const RawRouteData &rawRoute,
|
||||
PhantomNodes &phantomNodes,
|
||||
const DataFacadeT * facade
|
||||
) = 0;
|
||||
virtual void SetConfig(const DescriptorConfig & config) = 0;
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
|
||||
std::string tmp;
|
||||
public:
|
||||
void SetConfig(const DescriptorConfig& c) { config = c; }
|
||||
void SetConfig(const DescriptorConfig & c) { config = c; }
|
||||
|
||||
//TODO: reorder parameters
|
||||
void Run(
|
||||
|
@ -100,10 +100,13 @@ public:
|
||||
"\"status_message\": \"Cannot find route between points\",";
|
||||
}
|
||||
|
||||
description_factory.Run(facade, config.z);
|
||||
description_factory.Run(facade, config.zoom_level);
|
||||
reply.content += "\"route_geometry\": ";
|
||||
if(config.geometry) {
|
||||
description_factory.AppendEncodedPolylineString(reply.content, config.encodeGeometry);
|
||||
description_factory.AppendEncodedPolylineString(
|
||||
reply.content,
|
||||
config.encode_geometry
|
||||
);
|
||||
} else {
|
||||
reply.content += "[]";
|
||||
}
|
||||
@ -166,13 +169,16 @@ public:
|
||||
}
|
||||
alternateDescriptionFactory.SetEndSegment(phantom_nodes.targetPhantom);
|
||||
}
|
||||
alternateDescriptionFactory.Run(facade, config.z);
|
||||
alternateDescriptionFactory.Run(facade, config.zoom_level);
|
||||
|
||||
//give an array of alternative routes
|
||||
reply.content += "\"alternative_geometries\": [";
|
||||
if(config.geometry && INT_MAX != raw_route_information.lengthOfAlternativePath) {
|
||||
//Generate the linestrings for each alternative
|
||||
alternateDescriptionFactory.AppendEncodedPolylineString(reply.content, config.encodeGeometry);
|
||||
alternateDescriptionFactory.AppendEncodedPolylineString(
|
||||
reply.content,
|
||||
config.encode_geometry
|
||||
);
|
||||
}
|
||||
reply.content += "],";
|
||||
reply.content += "\"alternative_instructions\":[";
|
||||
|
Loading…
Reference in New Issue
Block a user