Refactoring base descriptor class
This commit is contained in:
parent
f4e015a255
commit
64c75c8b57
@ -44,11 +44,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct DescriptorConfig {
|
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 instructions;
|
||||||
bool geometry;
|
bool geometry;
|
||||||
bool encodeGeometry;
|
bool encode_geometry;
|
||||||
unsigned short z;
|
unsigned short zoom_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class DataFacadeT>
|
template<class DataFacadeT>
|
||||||
@ -57,7 +62,12 @@ public:
|
|||||||
BaseDescriptor() { }
|
BaseDescriptor() { }
|
||||||
//Maybe someone can explain the pure virtual destructor thing to me (dennis)
|
//Maybe someone can explain the pure virtual destructor thing to me (dennis)
|
||||||
virtual ~BaseDescriptor() { }
|
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;
|
virtual void SetConfig(const DescriptorConfig & config) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ private:
|
|||||||
|
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
public:
|
public:
|
||||||
void SetConfig(const DescriptorConfig& c) { config = c; }
|
void SetConfig(const DescriptorConfig & c) { config = c; }
|
||||||
|
|
||||||
//TODO: reorder parameters
|
//TODO: reorder parameters
|
||||||
void Run(
|
void Run(
|
||||||
|
@ -107,10 +107,13 @@ public:
|
|||||||
"\"status_message\": \"Cannot find route between points\",";
|
"\"status_message\": \"Cannot find route between points\",";
|
||||||
}
|
}
|
||||||
|
|
||||||
description_factory.Run(facade, config.z);
|
description_factory.Run(facade, config.zoom_level);
|
||||||
reply.content += "\"route_geometry\": ";
|
reply.content += "\"route_geometry\": ";
|
||||||
if(config.geometry) {
|
if(config.geometry) {
|
||||||
description_factory.AppendEncodedPolylineString(reply.content, config.encodeGeometry);
|
description_factory.AppendEncodedPolylineString(
|
||||||
|
reply.content,
|
||||||
|
config.encode_geometry
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
reply.content += "[]";
|
reply.content += "[]";
|
||||||
}
|
}
|
||||||
@ -173,13 +176,16 @@ public:
|
|||||||
}
|
}
|
||||||
alternateDescriptionFactory.SetEndSegment(phantom_nodes.targetPhantom);
|
alternateDescriptionFactory.SetEndSegment(phantom_nodes.targetPhantom);
|
||||||
}
|
}
|
||||||
alternateDescriptionFactory.Run(facade, config.z);
|
alternateDescriptionFactory.Run(facade, config.zoom_level);
|
||||||
|
|
||||||
//give an array of alternative routes
|
//give an array of alternative routes
|
||||||
reply.content += "\"alternative_geometries\": [";
|
reply.content += "\"alternative_geometries\": [";
|
||||||
if(config.geometry && INT_MAX != raw_route_information.lengthOfAlternativePath) {
|
if(config.geometry && INT_MAX != raw_route_information.lengthOfAlternativePath) {
|
||||||
//Generate the linestrings for each alternative
|
//Generate the linestrings for each alternative
|
||||||
alternateDescriptionFactory.AppendEncodedPolylineString(reply.content, config.encodeGeometry);
|
alternateDescriptionFactory.AppendEncodedPolylineString(
|
||||||
|
reply.content,
|
||||||
|
config.encode_geometry
|
||||||
|
);
|
||||||
}
|
}
|
||||||
reply.content += "],";
|
reply.content += "],";
|
||||||
reply.content += "\"alternative_instructions\":[";
|
reply.content += "\"alternative_instructions\":[";
|
||||||
|
Loading…
Reference in New Issue
Block a user