diff --git a/DataStructures/PhantomNodes.h b/DataStructures/PhantomNodes.h index 8aa1343d8..bb8630462 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/PhantomNodes.h @@ -63,7 +63,7 @@ struct PhantomNode { } int GetReverseWeightPlusOffset() const { - return reverse_weight + reverse_offset; + return reverse_weight - reverse_offset; } void Reset() { @@ -89,8 +89,14 @@ struct PhantomNode { bool isValid(const unsigned numberOfNodes) const { return location.isValid() && - ( (forward_node_id < numberOfNodes) || (reverse_node_id < numberOfNodes) ) && - ( (forward_weight != INVALID_EDGE_WEIGHT) || (reverse_weight != INVALID_EDGE_WEIGHT) ) && + ( + (forward_node_id < numberOfNodes) || + (reverse_node_id < numberOfNodes) + ) && + ( + (forward_weight != INVALID_EDGE_WEIGHT) || + (reverse_weight != INVALID_EDGE_WEIGHT) + ) && (ratio >= 0.) && (ratio <= 1.) && (name_id != std::numeric_limits::max()); @@ -102,6 +108,7 @@ struct PhantomNode { }; struct PhantomNodes { + //TODO: rename to lower-case non-camel PhantomNode startPhantom; PhantomNode targetPhantom; void Reset() { @@ -113,7 +120,6 @@ struct PhantomNodes { return (startPhantom.forward_node_id == targetPhantom.forward_node_id); } - //TODO: Rename to: BothPhantomNodesAreInvalid bool AtLeastOnePhantomNodeIsUINTMAX() const { return (startPhantom.forward_node_id == SPECIAL_NODEID) && (targetPhantom.forward_node_id == SPECIAL_NODEID); @@ -124,16 +130,26 @@ struct PhantomNodes { } }; -inline std::ostream& operator<<(std::ostream &out, const PhantomNodes & pn){ - out << "Node1: " << pn.startPhantom.forward_node_id << std::endl; - out << "Node2: " << pn.targetPhantom.reverse_node_id << std::endl; - out << "startCoord: " << pn.startPhantom.location << std::endl; - out << "targetCoord: " << pn.targetPhantom.location << std::endl; +inline std::ostream& operator<<(std::ostream &out, const PhantomNodes & pn) { + // out << "Node1: " << pn.startPhantom.forward_node_id << "\n"; + // out << "Node2: " << pn.targetPhantom.reverse_node_id << "\n"; + out << "start_coord: " << pn.startPhantom.location << "\n"; + out << "target_coord: " << pn.targetPhantom.location << std::endl; return out; } -inline std::ostream& operator<<(std::ostream &out, const PhantomNode & pn){ - out << "node1: " << pn.forward_node_id << ", node2: " << pn.reverse_node_id << ", name: " << pn.name_id << ", w1: " << pn.forward_weight << ", w2: " << pn.reverse_weight << ", ratio: " << pn.ratio << ", loc: " << pn.location; +inline std::ostream& operator<<(std::ostream &out, const PhantomNode & pn) { + out << "node1: " << pn.forward_node_id << ", " << + "node2: " << pn.reverse_node_id << ", " << + "name: " << pn.name_id << ", " << + "fwd-w: " << pn.forward_weight << ", " << + "rev-w: " << pn.reverse_weight << ", " << + "fwd-o: " << pn.forward_offset << ", " << + "rev-o: " << pn.reverse_offset << ", " << + "ratio: " << pn.ratio << ", " << + "geom: " << pn.packed_geometry_id << ", " << + "pos: " << pn.fwd_segment_position << ", " << + "loc: " << pn.location; return out; } diff --git a/RoutingAlgorithms/AlternativePathRouting.h b/RoutingAlgorithms/AlternativePathRouting.h index 4ea337f2a..96ec16a37 100644 --- a/RoutingAlgorithms/AlternativePathRouting.h +++ b/RoutingAlgorithms/AlternativePathRouting.h @@ -292,12 +292,17 @@ public: // SimpleLogger().Write(logDEBUG) << "packed_shortest_path.back(): " << packed_shortest_path.back(); super::UnpackPath( + // -- packed input packed_shortest_path, + // -- start of route + phantom_node_pair.startPhantom.packed_geometry_id, phantom_node_pair.startPhantom.fwd_segment_position, (packed_shortest_path.front() != phantom_node_pair.startPhantom.forward_node_id), + // -- end of route phantom_node_pair.targetPhantom.packed_geometry_id, phantom_node_pair.targetPhantom.fwd_segment_position, (packed_shortest_path.back() != phantom_node_pair.targetPhantom.forward_node_id), + // -- unpacked output raw_route_data.unpacked_path_segments.front() ); raw_route_data.lengthOfShortestPath = upper_bound_to_shortest_path_distance; @@ -361,7 +366,8 @@ private: // unpack, supply correct offsets to packed start and end nodes. super::UnpackPath( packed_s_v_path, - 0, false, SPECIAL_EDGEID, 0, false, //TODO: replace by real offsets + SPECIAL_EDGEID, 0, false, //TODO: replace with actual data + SPECIAL_EDGEID, 0, false, //TODO: replace with actual data unpacked_path ); } diff --git a/RoutingAlgorithms/BasicRoutingInterface.h b/RoutingAlgorithms/BasicRoutingInterface.h index 6e423f19f..fb479ce2b 100644 --- a/RoutingAlgorithms/BasicRoutingInterface.h +++ b/RoutingAlgorithms/BasicRoutingInterface.h @@ -140,6 +140,7 @@ public: //TODO: refactor parameters to only edge ids for start and end inline void UnpackPath( const std::vector & packed_path, + const unsigned packed_geometry_id_of_first_edge, const int fwd_index_offset, const bool start_traversed_in_reverse, const unsigned packed_geometry_id_of_last_edge, @@ -255,10 +256,18 @@ public: } if(SPECIAL_EDGEID != packed_geometry_id_of_last_edge) { SimpleLogger().Write(logDEBUG) << "unpacking last segment " << packed_geometry_id_of_last_edge; + SimpleLogger().Write(logDEBUG) << "target_traversed_in_reverse: " << (target_traversed_in_reverse ? "y" : "n"); std::vector id_vector; facade->GetUncompressedGeometry(packed_geometry_id_of_last_edge, id_vector); - const int start_index = 0; - const int end_index = rev_index_offset; + if( target_traversed_in_reverse ) { + std::reverse(id_vector.begin(), id_vector.end() ); + } + SimpleLogger().Write(logDEBUG) << "id_vector.size() " << id_vector.size(); + const bool start_and_end_on_same_edge = (packed_geometry_id_of_first_edge == packed_geometry_id_of_last_edge) && unpacked_path.empty(); + const int start_index = ( start_and_end_on_same_edge ? id_vector.size() - fwd_index_offset : 0 ); + const int end_index = (target_traversed_in_reverse ? id_vector.size() - rev_index_offset : rev_index_offset); + + SimpleLogger().Write(logDEBUG) << "fetching from [" << start_index << "," << end_index << "]"; BOOST_ASSERT( start_index >= 0 ); BOOST_ASSERT( start_index <= end_index ); diff --git a/RoutingAlgorithms/ShortestPathRouting.h b/RoutingAlgorithms/ShortestPathRouting.h index bab359ddd..daefdd5e0 100644 --- a/RoutingAlgorithms/ShortestPathRouting.h +++ b/RoutingAlgorithms/ShortestPathRouting.h @@ -364,8 +364,7 @@ public: BOOST_ASSERT(packed_legs1.size() == raw_route_data.unpacked_path_segments.size() ); super::UnpackPath( packed_legs1[i], - ( at_beginning ? start_offset : 0), - false, + SPECIAL_EDGEID, ( at_beginning ? start_offset : 0), false, SPECIAL_EDGEID, 0, false, raw_route_data.unpacked_path_segments[i] ); diff --git a/Server/RequestHandler.cpp b/Server/RequestHandler.cpp index 9dceb6852..664bdf35a 100644 --- a/Server/RequestHandler.cpp +++ b/Server/RequestHandler.cpp @@ -25,14 +25,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "RequestHandler.h" #include "APIGrammar.h" +#include "RequestHandler.h" +#include "Http/Request.h" #include "../Library/OSRM.h" #include "../Util/SimpleLogger.h" #include "../Util/StringUtil.h" #include "../typedefs.h" +#include #include #include diff --git a/Server/RequestHandler.h b/Server/RequestHandler.h index 320c0b5b7..ae7591aea 100644 --- a/Server/RequestHandler.h +++ b/Server/RequestHandler.h @@ -28,10 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef REQUEST_HANDLER_H #define REQUEST_HANDLER_H -#include "Http/Request.h" - -#include - #include #include @@ -41,6 +37,11 @@ struct APIGrammar; struct RouteParameters; class OSRM; +namespace http { + class Reply; + struct Request; +} + class RequestHandler : private boost::noncopyable { public: