Reworking data access to go always through facades
This commit is contained in:
parent
12b4fff81e
commit
0cabc81693
@ -50,7 +50,6 @@ public:
|
|||||||
SearchEngine( DataFacadeT * facade )
|
SearchEngine( DataFacadeT * facade )
|
||||||
:
|
:
|
||||||
facade (facade),
|
facade (facade),
|
||||||
engine_working_data(facade),
|
|
||||||
shortest_path (facade, engine_working_data),
|
shortest_path (facade, engine_working_data),
|
||||||
alternative_path (facade, engine_working_data)
|
alternative_path (facade, engine_working_data)
|
||||||
{}
|
{}
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
JSONDescriptor() : entered_restricted_area_count(0) {}
|
JSONDescriptor() : entered_restricted_area_count(0) {}
|
||||||
void SetConfig(const DescriptorConfig & c) { config = c; }
|
void SetConfig(const DescriptorConfig & c) { config = c; }
|
||||||
|
|
||||||
//TODO: reorder
|
//TODO: reorder parameters
|
||||||
void Run(
|
void Run(
|
||||||
http::Reply & reply,
|
http::Reply & reply,
|
||||||
const RawRouteData & raw_route_information,
|
const RawRouteData & raw_route_information,
|
||||||
|
@ -115,12 +115,12 @@ public:
|
|||||||
( routeParameters.alternateRoute ) &&
|
( routeParameters.alternateRoute ) &&
|
||||||
(1 == rawRoute.segmentEndCoordinates.size())
|
(1 == rawRoute.segmentEndCoordinates.size())
|
||||||
) {
|
) {
|
||||||
search_engine_ptr->alternativePaths(
|
search_engine_ptr->alternative_paths(
|
||||||
rawRoute.segmentEndCoordinates[0],
|
rawRoute.segmentEndCoordinates[0],
|
||||||
rawRoute
|
rawRoute
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
search_engine_ptr->shortestPath(
|
search_engine_ptr->shortest_path(
|
||||||
rawRoute.segmentEndCoordinates,
|
rawRoute.segmentEndCoordinates,
|
||||||
rawRoute
|
rawRoute
|
||||||
);
|
);
|
||||||
@ -139,16 +139,16 @@ public:
|
|||||||
reply.content += "(";
|
reply.content += "(";
|
||||||
}
|
}
|
||||||
|
|
||||||
_DescriptorConfig descriptorConfig;
|
DescriptorConfig descriptorConfig;
|
||||||
|
|
||||||
unsigned descriptorType = 0;
|
unsigned descriptorType = 0;
|
||||||
if(descriptorTable.find(routeParameters.outputFormat) != descriptorTable.end() ) {
|
if(descriptorTable.find(routeParameters.outputFormat) != descriptorTable.end() ) {
|
||||||
descriptorType = descriptorTable.find(routeParameters.outputFormat)->second;
|
descriptorType = descriptorTable.find(routeParameters.outputFormat)->second;
|
||||||
}
|
}
|
||||||
descriptorConfig.z = routeParameters.zoomLevel;
|
descriptorConfig.zoom_level = routeParameters.zoomLevel;
|
||||||
descriptorConfig.instructions = routeParameters.printInstructions;
|
descriptorConfig.instructions = routeParameters.printInstructions;
|
||||||
descriptorConfig.geometry = routeParameters.geometry;
|
descriptorConfig.geometry = routeParameters.geometry;
|
||||||
descriptorConfig.encodeGeometry = routeParameters.compression;
|
descriptorConfig.encode_geometry = routeParameters.compression;
|
||||||
|
|
||||||
switch(descriptorType){
|
switch(descriptorType){
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -47,12 +47,18 @@ class AlternativeRouting : private BasicRoutingInterface<DataFacadeT> {
|
|||||||
return (2*length + sharing) < (2*other.length + other.sharing);
|
return (2*length + sharing) < (2*other.length + other.sharing);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
DataFacadeT * facade;
|
||||||
const SearchGraph * search_graph;
|
|
||||||
SearchEngineData & engine_working_data;
|
SearchEngineData & engine_working_data;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AlternativeRouting(DataFacadeT & qd, SearchEngineData & engine_working_data) : super(qd), search_graph(qd.graph), engine_working_data(engine_working_data) { }
|
AlternativeRouting(
|
||||||
|
DataFacadeT * facade,
|
||||||
|
SearchEngineData & engine_working_data
|
||||||
|
) :
|
||||||
|
super(facade),
|
||||||
|
facade(facade),
|
||||||
|
engine_working_data(engine_working_data)
|
||||||
|
{ }
|
||||||
|
|
||||||
~AlternativeRouting() {}
|
~AlternativeRouting() {}
|
||||||
|
|
||||||
@ -252,8 +258,8 @@ private:
|
|||||||
//First partially unpack s-->v until paths deviate, note length of common path.
|
//First partially unpack s-->v until paths deviate, note length of common path.
|
||||||
for (unsigned i = 0, lengthOfPackedPath = std::min( packed_s_v_path.size(), packed_shortest_path.size()) - 1; (i < lengthOfPackedPath); ++i) {
|
for (unsigned i = 0, lengthOfPackedPath = std::min( packed_s_v_path.size(), packed_shortest_path.size()) - 1; (i < lengthOfPackedPath); ++i) {
|
||||||
if (packed_s_v_path[i] == packed_shortest_path[i] && packed_s_v_path[i + 1] == packed_shortest_path[i + 1]) {
|
if (packed_s_v_path[i] == packed_shortest_path[i] && packed_s_v_path[i + 1] == packed_shortest_path[i + 1]) {
|
||||||
typename SearchGraph::EdgeIterator edgeID = search_graph->FindEdgeInEitherDirection(packed_s_v_path[i], packed_s_v_path[i + 1]);
|
EdgeID edgeID = facade->FindEdgeInEitherDirection(packed_s_v_path[i], packed_s_v_path[i + 1]);
|
||||||
*sharing_of_via_path += search_graph->GetEdgeData(edgeID).distance;
|
*sharing_of_via_path += facade->GetEdgeData(edgeID).distance;
|
||||||
} else {
|
} else {
|
||||||
if (packed_s_v_path[i] == packed_shortest_path[i]) {
|
if (packed_s_v_path[i] == packed_shortest_path[i]) {
|
||||||
super::UnpackEdge(packed_s_v_path[i], packed_s_v_path[i+1], partiallyUnpackedViaPath);
|
super::UnpackEdge(packed_s_v_path[i], packed_s_v_path[i+1], partiallyUnpackedViaPath);
|
||||||
@ -264,8 +270,8 @@ private:
|
|||||||
}
|
}
|
||||||
//traverse partially unpacked edge and note common prefix
|
//traverse partially unpacked edge and note common prefix
|
||||||
for (int i = 0, lengthOfPackedPath = std::min( partiallyUnpackedViaPath.size(), partiallyUnpackedShortestPath.size()) - 1; (i < lengthOfPackedPath) && (partiallyUnpackedViaPath[i] == partiallyUnpackedShortestPath[i] && partiallyUnpackedViaPath[i+1] == partiallyUnpackedShortestPath[i+1]); ++i) {
|
for (int i = 0, lengthOfPackedPath = std::min( partiallyUnpackedViaPath.size(), partiallyUnpackedShortestPath.size()) - 1; (i < lengthOfPackedPath) && (partiallyUnpackedViaPath[i] == partiallyUnpackedShortestPath[i] && partiallyUnpackedViaPath[i+1] == partiallyUnpackedShortestPath[i+1]); ++i) {
|
||||||
typename SearchGraph::EdgeIterator edgeID = search_graph->FindEdgeInEitherDirection(partiallyUnpackedViaPath[i], partiallyUnpackedViaPath[i+1]);
|
EdgeID edgeID = facade->FindEdgeInEitherDirection(partiallyUnpackedViaPath[i], partiallyUnpackedViaPath[i+1]);
|
||||||
*sharing_of_via_path += search_graph->GetEdgeData(edgeID).distance;
|
*sharing_of_via_path += facade->GetEdgeData(edgeID).distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Second, partially unpack v-->t in reverse order until paths deviate and note lengths
|
//Second, partially unpack v-->t in reverse order until paths deviate and note lengths
|
||||||
@ -273,8 +279,8 @@ private:
|
|||||||
int shortestPathIndex = packed_shortest_path.size() - 1;
|
int shortestPathIndex = packed_shortest_path.size() - 1;
|
||||||
for (; viaPathIndex > 0 && shortestPathIndex > 0; --viaPathIndex,--shortestPathIndex ) {
|
for (; viaPathIndex > 0 && shortestPathIndex > 0; --viaPathIndex,--shortestPathIndex ) {
|
||||||
if (packed_v_t_path[viaPathIndex - 1] == packed_shortest_path[shortestPathIndex - 1] && packed_v_t_path[viaPathIndex] == packed_shortest_path[shortestPathIndex]) {
|
if (packed_v_t_path[viaPathIndex - 1] == packed_shortest_path[shortestPathIndex - 1] && packed_v_t_path[viaPathIndex] == packed_shortest_path[shortestPathIndex]) {
|
||||||
typename SearchGraph::EdgeIterator edgeID = search_graph->FindEdgeInEitherDirection( packed_v_t_path[viaPathIndex - 1], packed_v_t_path[viaPathIndex]);
|
EdgeID edgeID = facade->FindEdgeInEitherDirection( packed_v_t_path[viaPathIndex - 1], packed_v_t_path[viaPathIndex]);
|
||||||
*sharing_of_via_path += search_graph->GetEdgeData(edgeID).distance;
|
*sharing_of_via_path += facade->GetEdgeData(edgeID).distance;
|
||||||
} else {
|
} else {
|
||||||
if (packed_v_t_path[viaPathIndex] == packed_shortest_path[shortestPathIndex]) {
|
if (packed_v_t_path[viaPathIndex] == packed_shortest_path[shortestPathIndex]) {
|
||||||
super::UnpackEdge(packed_v_t_path[viaPathIndex-1], packed_v_t_path[viaPathIndex], partiallyUnpackedViaPath);
|
super::UnpackEdge(packed_v_t_path[viaPathIndex-1], packed_v_t_path[viaPathIndex], partiallyUnpackedViaPath);
|
||||||
@ -288,8 +294,8 @@ private:
|
|||||||
shortestPathIndex = partiallyUnpackedShortestPath.size() - 1;
|
shortestPathIndex = partiallyUnpackedShortestPath.size() - 1;
|
||||||
for (; viaPathIndex > 0 && shortestPathIndex > 0; --viaPathIndex,--shortestPathIndex) {
|
for (; viaPathIndex > 0 && shortestPathIndex > 0; --viaPathIndex,--shortestPathIndex) {
|
||||||
if (partiallyUnpackedViaPath[viaPathIndex - 1] == partiallyUnpackedShortestPath[shortestPathIndex - 1] && partiallyUnpackedViaPath[viaPathIndex] == partiallyUnpackedShortestPath[shortestPathIndex]) {
|
if (partiallyUnpackedViaPath[viaPathIndex - 1] == partiallyUnpackedShortestPath[shortestPathIndex - 1] && partiallyUnpackedViaPath[viaPathIndex] == partiallyUnpackedShortestPath[shortestPathIndex]) {
|
||||||
typename SearchGraph::EdgeIterator edgeID = search_graph->FindEdgeInEitherDirection( partiallyUnpackedViaPath[viaPathIndex - 1], partiallyUnpackedViaPath[viaPathIndex]);
|
EdgeID edgeID = facade->FindEdgeInEitherDirection( partiallyUnpackedViaPath[viaPathIndex - 1], partiallyUnpackedViaPath[viaPathIndex]);
|
||||||
*sharing_of_via_path += search_graph->GetEdgeData(edgeID).distance;
|
*sharing_of_via_path += facade->GetEdgeData(edgeID).distance;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -309,8 +315,8 @@ private:
|
|||||||
//compute forward sharing
|
//compute forward sharing
|
||||||
while( (packedAlternativePath[aindex] == packedShortestPath[aindex]) && (packedAlternativePath[aindex+1] == packedShortestPath[aindex+1]) ) {
|
while( (packedAlternativePath[aindex] == packedShortestPath[aindex]) && (packedAlternativePath[aindex+1] == packedShortestPath[aindex+1]) ) {
|
||||||
// SimpleLogger().Write() << "retrieving edge (" << packedAlternativePath[aindex] << "," << packedAlternativePath[aindex+1] << ")";
|
// SimpleLogger().Write() << "retrieving edge (" << packedAlternativePath[aindex] << "," << packedAlternativePath[aindex+1] << ")";
|
||||||
typename SearchGraph::EdgeIterator edgeID = search_graph->FindEdgeInEitherDirection(packedAlternativePath[aindex], packedAlternativePath[aindex+1]);
|
EdgeID edgeID = facade->FindEdgeInEitherDirection(packedAlternativePath[aindex], packedAlternativePath[aindex+1]);
|
||||||
sharing += search_graph->GetEdgeData(edgeID).distance;
|
sharing += facade->GetEdgeData(edgeID).distance;
|
||||||
++aindex;
|
++aindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,8 +324,8 @@ private:
|
|||||||
int bindex = packedShortestPath.size()-1;
|
int bindex = packedShortestPath.size()-1;
|
||||||
//compute backward sharing
|
//compute backward sharing
|
||||||
while( aindex > 0 && bindex > 0 && (packedAlternativePath[aindex] == packedShortestPath[bindex]) && (packedAlternativePath[aindex-1] == packedShortestPath[bindex-1]) ) {
|
while( aindex > 0 && bindex > 0 && (packedAlternativePath[aindex] == packedShortestPath[bindex]) && (packedAlternativePath[aindex-1] == packedShortestPath[bindex-1]) ) {
|
||||||
typename SearchGraph::EdgeIterator edgeID = search_graph->FindEdgeInEitherDirection(packedAlternativePath[aindex], packedAlternativePath[aindex-1]);
|
EdgeID edgeID = facade->FindEdgeInEitherDirection(packedAlternativePath[aindex], packedAlternativePath[aindex-1]);
|
||||||
sharing += search_graph->GetEdgeData(edgeID).distance;
|
sharing += facade->GetEdgeData(edgeID).distance;
|
||||||
--aindex; --bindex;
|
--aindex; --bindex;
|
||||||
}
|
}
|
||||||
return sharing;
|
return sharing;
|
||||||
@ -357,12 +363,12 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( typename SearchGraph::EdgeIterator edge = search_graph->BeginEdges( node ); edge < search_graph->EndEdges(node); edge++ ) {
|
for ( EdgeID edge = facade->BeginEdges( node ); edge < facade->EndEdges(node); edge++ ) {
|
||||||
const typename SearchGraph::EdgeData & data = search_graph->GetEdgeData(edge);
|
const typename SearchGraph::EdgeData & data = facade->GetEdgeData(edge);
|
||||||
bool forwardDirectionFlag = (forwardDirection ? data.forward : data.backward );
|
bool forwardDirectionFlag = (forwardDirection ? data.forward : data.backward );
|
||||||
if(forwardDirectionFlag) {
|
if(forwardDirectionFlag) {
|
||||||
|
|
||||||
const NodeID to = search_graph->GetTarget(edge);
|
const NodeID to = facade->GetTarget(edge);
|
||||||
const int edgeWeight = data.distance;
|
const int edgeWeight = data.distance;
|
||||||
|
|
||||||
assert( edgeWeight > 0 );
|
assert( edgeWeight > 0 );
|
||||||
@ -432,8 +438,8 @@ private:
|
|||||||
std::stack<SearchSpaceEdge> unpackStack;
|
std::stack<SearchSpaceEdge> unpackStack;
|
||||||
//Traverse path s-->v
|
//Traverse path s-->v
|
||||||
for (unsigned i = packed_s_v_path.size() - 1; (i > 0) && unpackStack.empty(); --i) {
|
for (unsigned i = packed_s_v_path.size() - 1; (i > 0) && unpackStack.empty(); --i) {
|
||||||
typename SearchGraph::EdgeIterator edgeID = search_graph->FindEdgeInEitherDirection( packed_s_v_path[i - 1], packed_s_v_path[i]);
|
EdgeID edgeID = facade->FindEdgeInEitherDirection( packed_s_v_path[i - 1], packed_s_v_path[i]);
|
||||||
int lengthOfCurrentEdge = search_graph->GetEdgeData(edgeID).distance;
|
int lengthOfCurrentEdge = facade->GetEdgeData(edgeID).distance;
|
||||||
if (lengthOfCurrentEdge + unpackedUntilDistance >= T_threshold) {
|
if (lengthOfCurrentEdge + unpackedUntilDistance >= T_threshold) {
|
||||||
unpackStack.push(std::make_pair(packed_s_v_path[i - 1], packed_s_v_path[i]));
|
unpackStack.push(std::make_pair(packed_s_v_path[i - 1], packed_s_v_path[i]));
|
||||||
} else {
|
} else {
|
||||||
@ -445,15 +451,15 @@ private:
|
|||||||
while (!unpackStack.empty()) {
|
while (!unpackStack.empty()) {
|
||||||
const SearchSpaceEdge viaPathEdge = unpackStack.top();
|
const SearchSpaceEdge viaPathEdge = unpackStack.top();
|
||||||
unpackStack.pop();
|
unpackStack.pop();
|
||||||
typename SearchGraph::EdgeIterator edgeIDInViaPath = search_graph->FindEdgeInEitherDirection(viaPathEdge.first, viaPathEdge.second);
|
EdgeID edgeIDInViaPath = facade->FindEdgeInEitherDirection(viaPathEdge.first, viaPathEdge.second);
|
||||||
if(UINT_MAX == edgeIDInViaPath)
|
if(UINT_MAX == edgeIDInViaPath)
|
||||||
return false;
|
return false;
|
||||||
typename SearchGraph::EdgeData currentEdgeData = search_graph->GetEdgeData(edgeIDInViaPath);
|
typename SearchGraph::EdgeData currentEdgeData = facade->GetEdgeData(edgeIDInViaPath);
|
||||||
bool IsViaEdgeShortCut = currentEdgeData.shortcut;
|
bool IsViaEdgeShortCut = currentEdgeData.shortcut;
|
||||||
if (IsViaEdgeShortCut) {
|
if (IsViaEdgeShortCut) {
|
||||||
const NodeID middleOfViaPath = currentEdgeData.id;
|
const NodeID middleOfViaPath = currentEdgeData.id;
|
||||||
typename SearchGraph::EdgeIterator edgeIDOfSecondSegment = search_graph->FindEdgeInEitherDirection(middleOfViaPath, viaPathEdge.second);
|
EdgeID edgeIDOfSecondSegment = facade->FindEdgeInEitherDirection(middleOfViaPath, viaPathEdge.second);
|
||||||
int lengthOfSecondSegment = search_graph->GetEdgeData(edgeIDOfSecondSegment).distance;
|
int lengthOfSecondSegment = facade->GetEdgeData(edgeIDOfSecondSegment).distance;
|
||||||
//attention: !unpacking in reverse!
|
//attention: !unpacking in reverse!
|
||||||
//Check if second segment is the one to go over treshold? if yes add second segment to stack, else push first segment to stack and add distance of second one.
|
//Check if second segment is the one to go over treshold? if yes add second segment to stack, else push first segment to stack and add distance of second one.
|
||||||
if (unpackedUntilDistance + lengthOfSecondSegment >= T_threshold) {
|
if (unpackedUntilDistance + lengthOfSecondSegment >= T_threshold) {
|
||||||
@ -473,8 +479,8 @@ private:
|
|||||||
unpackedUntilDistance = 0;
|
unpackedUntilDistance = 0;
|
||||||
//Traverse path s-->v
|
//Traverse path s-->v
|
||||||
for (unsigned i = 0, lengthOfPackedPath = packed_v_t_path.size() - 1; (i < lengthOfPackedPath) && unpackStack.empty(); ++i) {
|
for (unsigned i = 0, lengthOfPackedPath = packed_v_t_path.size() - 1; (i < lengthOfPackedPath) && unpackStack.empty(); ++i) {
|
||||||
typename SearchGraph::EdgeIterator edgeID = search_graph->FindEdgeInEitherDirection( packed_v_t_path[i], packed_v_t_path[i + 1]);
|
EdgeID edgeID = facade->FindEdgeInEitherDirection( packed_v_t_path[i], packed_v_t_path[i + 1]);
|
||||||
int lengthOfCurrentEdge = search_graph->GetEdgeData(edgeID).distance;
|
int lengthOfCurrentEdge = facade->GetEdgeData(edgeID).distance;
|
||||||
if (lengthOfCurrentEdge + unpackedUntilDistance >= T_threshold) {
|
if (lengthOfCurrentEdge + unpackedUntilDistance >= T_threshold) {
|
||||||
unpackStack.push( std::make_pair(packed_v_t_path[i], packed_v_t_path[i + 1]));
|
unpackStack.push( std::make_pair(packed_v_t_path[i], packed_v_t_path[i + 1]));
|
||||||
} else {
|
} else {
|
||||||
@ -486,15 +492,15 @@ private:
|
|||||||
while (!unpackStack.empty()) {
|
while (!unpackStack.empty()) {
|
||||||
const SearchSpaceEdge viaPathEdge = unpackStack.top();
|
const SearchSpaceEdge viaPathEdge = unpackStack.top();
|
||||||
unpackStack.pop();
|
unpackStack.pop();
|
||||||
typename SearchGraph::EdgeIterator edgeIDInViaPath = search_graph->FindEdgeInEitherDirection(viaPathEdge.first, viaPathEdge.second);
|
EdgeID edgeIDInViaPath = facade->FindEdgeInEitherDirection(viaPathEdge.first, viaPathEdge.second);
|
||||||
if(UINT_MAX == edgeIDInViaPath)
|
if(UINT_MAX == edgeIDInViaPath)
|
||||||
return false;
|
return false;
|
||||||
typename SearchGraph::EdgeData currentEdgeData = search_graph->GetEdgeData(edgeIDInViaPath);
|
typename SearchGraph::EdgeData currentEdgeData = facade->GetEdgeData(edgeIDInViaPath);
|
||||||
const bool IsViaEdgeShortCut = currentEdgeData.shortcut;
|
const bool IsViaEdgeShortCut = currentEdgeData.shortcut;
|
||||||
if (IsViaEdgeShortCut) {
|
if (IsViaEdgeShortCut) {
|
||||||
const NodeID middleOfViaPath = currentEdgeData.id;
|
const NodeID middleOfViaPath = currentEdgeData.id;
|
||||||
typename SearchGraph::EdgeIterator edgeIDOfFirstSegment = search_graph->FindEdgeInEitherDirection(viaPathEdge.first, middleOfViaPath);
|
EdgeID edgeIDOfFirstSegment = facade->FindEdgeInEitherDirection(viaPathEdge.first, middleOfViaPath);
|
||||||
int lengthOfFirstSegment = search_graph->GetEdgeData( edgeIDOfFirstSegment).distance;
|
int lengthOfFirstSegment = facade->GetEdgeData( edgeIDOfFirstSegment).distance;
|
||||||
//Check if first segment is the one to go over treshold? if yes first segment to stack, else push second segment to stack and add distance of first one.
|
//Check if first segment is the one to go over treshold? if yes first segment to stack, else push second segment to stack and add distance of first one.
|
||||||
if (unpackedUntilDistance + lengthOfFirstSegment >= T_threshold) {
|
if (unpackedUntilDistance + lengthOfFirstSegment >= T_threshold) {
|
||||||
unpackStack.push( std::make_pair(viaPathEdge.first, middleOfViaPath));
|
unpackStack.push( std::make_pair(viaPathEdge.first, middleOfViaPath));
|
||||||
|
@ -35,12 +35,12 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
template<class SearchEngineDataT>
|
template<class DataFacadeT>
|
||||||
class BasicRoutingInterface : boost::noncopyable{
|
class BasicRoutingInterface : boost::noncopyable{
|
||||||
protected:
|
protected:
|
||||||
SearchEngineDataT * engine_working_data;
|
DataFacadeT * facade;
|
||||||
public:
|
public:
|
||||||
BasicRoutingInterface(SearchEngineDataT * engine_working_data) : engine_working_data(engine_working_data) { }
|
BasicRoutingInterface(DataFacadeT * facade) : facade(facade) { }
|
||||||
virtual ~BasicRoutingInterface(){ };
|
virtual ~BasicRoutingInterface(){ };
|
||||||
|
|
||||||
inline void RoutingStep(
|
inline void RoutingStep(
|
||||||
@ -72,14 +72,14 @@ public:
|
|||||||
|
|
||||||
//Stalling
|
//Stalling
|
||||||
for(
|
for(
|
||||||
EdgeID edge = engine_working_data->BeginEdges( node );
|
EdgeID edge = facade->BeginEdges( node );
|
||||||
edge < engine_working_data->EndEdges(node);
|
edge < facade->EndEdges(node);
|
||||||
++edge
|
++edge
|
||||||
) {
|
) {
|
||||||
const typename SearchEngineDataT::EdgeData & data = engine_working_data->GetEdgeData(edge);
|
const typename DataFacadeT::EdgeData & data = facade->GetEdgeData(edge);
|
||||||
bool backwardDirectionFlag = (!forwardDirection) ? data.forward : data.backward;
|
bool backwardDirectionFlag = (!forwardDirection) ? data.forward : data.backward;
|
||||||
if(backwardDirectionFlag) {
|
if(backwardDirectionFlag) {
|
||||||
const NodeID to = engine_working_data->GetTarget(edge);
|
const NodeID to = facade->GetTarget(edge);
|
||||||
const int edgeWeight = data.distance;
|
const int edgeWeight = data.distance;
|
||||||
|
|
||||||
assert( edgeWeight > 0 );
|
assert( edgeWeight > 0 );
|
||||||
@ -92,12 +92,12 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( EdgeID edge = engine_working_data->BeginEdges( node ); edge < engine_working_data->EndEdges(node); ++edge ) {
|
for ( EdgeID edge = facade->BeginEdges( node ); edge < facade->EndEdges(node); ++edge ) {
|
||||||
const typename SearchEngineDataT::EdgeData & data = engine_working_data->GetEdgeData(edge);
|
const typename DataFacadeT::EdgeData & data = facade->GetEdgeData(edge);
|
||||||
bool forwardDirectionFlag = (forwardDirection ? data.forward : data.backward );
|
bool forwardDirectionFlag = (forwardDirection ? data.forward : data.backward );
|
||||||
if(forwardDirectionFlag) {
|
if(forwardDirectionFlag) {
|
||||||
|
|
||||||
const NodeID to = engine_working_data->GetTarget(edge);
|
const NodeID to = facade->GetTarget(edge);
|
||||||
const int edgeWeight = data.distance;
|
const int edgeWeight = data.distance;
|
||||||
|
|
||||||
assert( edgeWeight > 0 );
|
assert( edgeWeight > 0 );
|
||||||
@ -133,18 +133,18 @@ public:
|
|||||||
|
|
||||||
EdgeID smallestEdge = SPECIAL_EDGEID;
|
EdgeID smallestEdge = SPECIAL_EDGEID;
|
||||||
int smallestWeight = INT_MAX;
|
int smallestWeight = INT_MAX;
|
||||||
for(EdgeID eit = engine_working_data->BeginEdges(edge.first);eit < engine_working_data->EndEdges(edge.first);++eit){
|
for(EdgeID eit = facade->BeginEdges(edge.first);eit < facade->EndEdges(edge.first);++eit){
|
||||||
const int weight = engine_working_data->GetEdgeData(eit).distance;
|
const int weight = facade->GetEdgeData(eit).distance;
|
||||||
if(engine_working_data->GetTarget(eit) == edge.second && weight < smallestWeight && engine_working_data->GetEdgeData(eit).forward){
|
if(facade->GetTarget(eit) == edge.second && weight < smallestWeight && facade->GetEdgeData(eit).forward){
|
||||||
smallestEdge = eit;
|
smallestEdge = eit;
|
||||||
smallestWeight = weight;
|
smallestWeight = weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(smallestEdge == SPECIAL_EDGEID){
|
if(smallestEdge == SPECIAL_EDGEID){
|
||||||
for(EdgeID eit = engine_working_data->BeginEdges(edge.second);eit < engine_working_data->EndEdges(edge.second);++eit){
|
for(EdgeID eit = facade->BeginEdges(edge.second);eit < facade->EndEdges(edge.second);++eit){
|
||||||
const int weight = engine_working_data->GetEdgeData(eit).distance;
|
const int weight = facade->GetEdgeData(eit).distance;
|
||||||
if(engine_working_data->GetTarget(eit) == edge.first && weight < smallestWeight && engine_working_data->GetEdgeData(eit).backward){
|
if(facade->GetTarget(eit) == edge.first && weight < smallestWeight && facade->GetEdgeData(eit).backward){
|
||||||
smallestEdge = eit;
|
smallestEdge = eit;
|
||||||
smallestWeight = weight;
|
smallestWeight = weight;
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ public:
|
|||||||
}
|
}
|
||||||
assert(smallestWeight != INT_MAX);
|
assert(smallestWeight != INT_MAX);
|
||||||
|
|
||||||
const typename SearchEngineDataT::EdgeData& ed = engine_working_data->GetEdgeData(smallestEdge);
|
const typename DataFacadeT::EdgeData& ed = facade->GetEdgeData(smallestEdge);
|
||||||
if(ed.shortcut) {//unpack
|
if(ed.shortcut) {//unpack
|
||||||
const NodeID middle = ed.id;
|
const NodeID middle = ed.id;
|
||||||
//again, we need to this in reversed order
|
//again, we need to this in reversed order
|
||||||
@ -163,8 +163,8 @@ public:
|
|||||||
unpackedPath.push_back(
|
unpackedPath.push_back(
|
||||||
_PathData(
|
_PathData(
|
||||||
ed.id,
|
ed.id,
|
||||||
engine_working_data->GetNameIndexFromEdgeID(ed.id),
|
facade->GetNameIndexFromEdgeID(ed.id),
|
||||||
engine_working_data->GetTurnInstructionForEdgeID(ed.id),
|
facade->GetTurnInstructionForEdgeID(ed.id),
|
||||||
ed.distance
|
ed.distance
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -183,18 +183,18 @@ public:
|
|||||||
|
|
||||||
EdgeID smallestEdge = SPECIAL_EDGEID;
|
EdgeID smallestEdge = SPECIAL_EDGEID;
|
||||||
int smallestWeight = INT_MAX;
|
int smallestWeight = INT_MAX;
|
||||||
for(EdgeID eit = engine_working_data->BeginEdges(edge.first);eit < engine_working_data->EndEdges(edge.first);++eit){
|
for(EdgeID eit = facade->BeginEdges(edge.first);eit < facade->EndEdges(edge.first);++eit){
|
||||||
const int weight = engine_working_data->GetEdgeData(eit).distance;
|
const int weight = facade->GetEdgeData(eit).distance;
|
||||||
if(engine_working_data->GetTarget(eit) == edge.second && weight < smallestWeight && engine_working_data->GetEdgeData(eit).forward){
|
if(facade->GetTarget(eit) == edge.second && weight < smallestWeight && facade->GetEdgeData(eit).forward){
|
||||||
smallestEdge = eit;
|
smallestEdge = eit;
|
||||||
smallestWeight = weight;
|
smallestWeight = weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(smallestEdge == SPECIAL_EDGEID){
|
if(smallestEdge == SPECIAL_EDGEID){
|
||||||
for(EdgeID eit = engine_working_data->BeginEdges(edge.second);eit < engine_working_data->EndEdges(edge.second);++eit){
|
for(EdgeID eit = facade->BeginEdges(edge.second);eit < facade->EndEdges(edge.second);++eit){
|
||||||
const int weight = engine_working_data->GetEdgeData(eit).distance;
|
const int weight = facade->GetEdgeData(eit).distance;
|
||||||
if(engine_working_data->GetTarget(eit) == edge.first && weight < smallestWeight && engine_working_data->GetEdgeData(eit).backward){
|
if(facade->GetTarget(eit) == edge.first && weight < smallestWeight && facade->GetEdgeData(eit).backward){
|
||||||
smallestEdge = eit;
|
smallestEdge = eit;
|
||||||
smallestWeight = weight;
|
smallestWeight = weight;
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@ public:
|
|||||||
}
|
}
|
||||||
assert(smallestWeight != INT_MAX);
|
assert(smallestWeight != INT_MAX);
|
||||||
|
|
||||||
const typename SearchEngineDataT::EdgeData& ed = engine_working_data->GetEdgeData(smallestEdge);
|
const typename DataFacadeT::EdgeData& ed = facade->GetEdgeData(smallestEdge);
|
||||||
if(ed.shortcut) {//unpack
|
if(ed.shortcut) {//unpack
|
||||||
const NodeID middle = ed.id;
|
const NodeID middle = ed.id;
|
||||||
//again, we need to this in reversed order
|
//again, we need to this in reversed order
|
||||||
|
@ -27,13 +27,13 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
#include "../DataStructures/SearchEngineData.h"
|
#include "../DataStructures/SearchEngineData.h"
|
||||||
|
|
||||||
template<class QueryDataT>
|
template<class DataFacadeT>
|
||||||
class ShortestPathRouting : public BasicRoutingInterface<QueryDataT>{
|
class ShortestPathRouting : public BasicRoutingInterface<DataFacadeT>{
|
||||||
typedef BasicRoutingInterface<QueryDataT> super;
|
typedef BasicRoutingInterface<DataFacadeT> super;
|
||||||
typedef typename QueryDataT::QueryHeap QueryHeap;
|
typedef SearchEngineData::QueryHeap QueryHeap;
|
||||||
SearchEngineData & engine_working_data;
|
SearchEngineData & engine_working_data;
|
||||||
public:
|
public:
|
||||||
ShortestPathRouting( QueryDataT & qd, SearchEngineData & engine_working_data) : super(qd), engine_working_data(engine_working_data) {}
|
ShortestPathRouting( DataFacadeT * facade, SearchEngineData & engine_working_data) : super(facade), engine_working_data(engine_working_data) {}
|
||||||
|
|
||||||
~ShortestPathRouting() {}
|
~ShortestPathRouting() {}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user