unpacking target correctly, also partial unpacking origin and destination are on the very same packed edge
This commit is contained in:
parent
eca09e6c81
commit
6b91d6692f
@ -63,7 +63,7 @@ struct PhantomNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int GetReverseWeightPlusOffset() const {
|
int GetReverseWeightPlusOffset() const {
|
||||||
return reverse_weight + reverse_offset;
|
return reverse_weight - reverse_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reset() {
|
void Reset() {
|
||||||
@ -89,8 +89,14 @@ struct PhantomNode {
|
|||||||
bool isValid(const unsigned numberOfNodes) const {
|
bool isValid(const unsigned numberOfNodes) const {
|
||||||
return
|
return
|
||||||
location.isValid() &&
|
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 >= 0.) &&
|
||||||
(ratio <= 1.) &&
|
(ratio <= 1.) &&
|
||||||
(name_id != std::numeric_limits<unsigned>::max());
|
(name_id != std::numeric_limits<unsigned>::max());
|
||||||
@ -102,6 +108,7 @@ struct PhantomNode {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct PhantomNodes {
|
struct PhantomNodes {
|
||||||
|
//TODO: rename to lower-case non-camel
|
||||||
PhantomNode startPhantom;
|
PhantomNode startPhantom;
|
||||||
PhantomNode targetPhantom;
|
PhantomNode targetPhantom;
|
||||||
void Reset() {
|
void Reset() {
|
||||||
@ -113,7 +120,6 @@ struct PhantomNodes {
|
|||||||
return (startPhantom.forward_node_id == targetPhantom.forward_node_id);
|
return (startPhantom.forward_node_id == targetPhantom.forward_node_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: Rename to: BothPhantomNodesAreInvalid
|
//TODO: Rename to: BothPhantomNodesAreInvalid
|
||||||
bool AtLeastOnePhantomNodeIsUINTMAX() const {
|
bool AtLeastOnePhantomNodeIsUINTMAX() const {
|
||||||
return (startPhantom.forward_node_id == SPECIAL_NODEID) && (targetPhantom.forward_node_id == SPECIAL_NODEID);
|
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){
|
inline std::ostream& operator<<(std::ostream &out, const PhantomNodes & pn) {
|
||||||
out << "Node1: " << pn.startPhantom.forward_node_id << std::endl;
|
// out << "Node1: " << pn.startPhantom.forward_node_id << "\n";
|
||||||
out << "Node2: " << pn.targetPhantom.reverse_node_id << std::endl;
|
// out << "Node2: " << pn.targetPhantom.reverse_node_id << "\n";
|
||||||
out << "startCoord: " << pn.startPhantom.location << std::endl;
|
out << "start_coord: " << pn.startPhantom.location << "\n";
|
||||||
out << "targetCoord: " << pn.targetPhantom.location << std::endl;
|
out << "target_coord: " << pn.targetPhantom.location << std::endl;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::ostream& operator<<(std::ostream &out, const PhantomNode & pn){
|
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;
|
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;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,12 +292,17 @@ public:
|
|||||||
// SimpleLogger().Write(logDEBUG) << "packed_shortest_path.back(): " << packed_shortest_path.back();
|
// SimpleLogger().Write(logDEBUG) << "packed_shortest_path.back(): " << packed_shortest_path.back();
|
||||||
|
|
||||||
super::UnpackPath(
|
super::UnpackPath(
|
||||||
|
// -- packed input
|
||||||
packed_shortest_path,
|
packed_shortest_path,
|
||||||
|
// -- start of route
|
||||||
|
phantom_node_pair.startPhantom.packed_geometry_id,
|
||||||
phantom_node_pair.startPhantom.fwd_segment_position,
|
phantom_node_pair.startPhantom.fwd_segment_position,
|
||||||
(packed_shortest_path.front() != phantom_node_pair.startPhantom.forward_node_id),
|
(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.packed_geometry_id,
|
||||||
phantom_node_pair.targetPhantom.fwd_segment_position,
|
phantom_node_pair.targetPhantom.fwd_segment_position,
|
||||||
(packed_shortest_path.back() != phantom_node_pair.targetPhantom.forward_node_id),
|
(packed_shortest_path.back() != phantom_node_pair.targetPhantom.forward_node_id),
|
||||||
|
// -- unpacked output
|
||||||
raw_route_data.unpacked_path_segments.front()
|
raw_route_data.unpacked_path_segments.front()
|
||||||
);
|
);
|
||||||
raw_route_data.lengthOfShortestPath = upper_bound_to_shortest_path_distance;
|
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.
|
// unpack, supply correct offsets to packed start and end nodes.
|
||||||
super::UnpackPath(
|
super::UnpackPath(
|
||||||
packed_s_v_path,
|
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
|
unpacked_path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,7 @@ public:
|
|||||||
//TODO: refactor parameters to only edge ids for start and end
|
//TODO: refactor parameters to only edge ids for start and end
|
||||||
inline void UnpackPath(
|
inline void UnpackPath(
|
||||||
const std::vector<NodeID> & packed_path,
|
const std::vector<NodeID> & packed_path,
|
||||||
|
const unsigned packed_geometry_id_of_first_edge,
|
||||||
const int fwd_index_offset,
|
const int fwd_index_offset,
|
||||||
const bool start_traversed_in_reverse,
|
const bool start_traversed_in_reverse,
|
||||||
const unsigned packed_geometry_id_of_last_edge,
|
const unsigned packed_geometry_id_of_last_edge,
|
||||||
@ -255,10 +256,18 @@ public:
|
|||||||
}
|
}
|
||||||
if(SPECIAL_EDGEID != packed_geometry_id_of_last_edge) {
|
if(SPECIAL_EDGEID != packed_geometry_id_of_last_edge) {
|
||||||
SimpleLogger().Write(logDEBUG) << "unpacking last segment " << 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<unsigned> id_vector;
|
std::vector<unsigned> id_vector;
|
||||||
facade->GetUncompressedGeometry(packed_geometry_id_of_last_edge, id_vector);
|
facade->GetUncompressedGeometry(packed_geometry_id_of_last_edge, id_vector);
|
||||||
const int start_index = 0;
|
if( target_traversed_in_reverse ) {
|
||||||
const int end_index = rev_index_offset;
|
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 >= 0 );
|
||||||
BOOST_ASSERT( start_index <= end_index );
|
BOOST_ASSERT( start_index <= end_index );
|
||||||
|
@ -364,8 +364,7 @@ public:
|
|||||||
BOOST_ASSERT(packed_legs1.size() == raw_route_data.unpacked_path_segments.size() );
|
BOOST_ASSERT(packed_legs1.size() == raw_route_data.unpacked_path_segments.size() );
|
||||||
super::UnpackPath(
|
super::UnpackPath(
|
||||||
packed_legs1[i],
|
packed_legs1[i],
|
||||||
( at_beginning ? start_offset : 0),
|
SPECIAL_EDGEID, ( at_beginning ? start_offset : 0), false,
|
||||||
false,
|
|
||||||
SPECIAL_EDGEID, 0, false,
|
SPECIAL_EDGEID, 0, false,
|
||||||
raw_route_data.unpacked_path_segments[i]
|
raw_route_data.unpacked_path_segments[i]
|
||||||
);
|
);
|
||||||
|
@ -25,14 +25,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "RequestHandler.h"
|
|
||||||
#include "APIGrammar.h"
|
#include "APIGrammar.h"
|
||||||
|
#include "RequestHandler.h"
|
||||||
|
#include "Http/Request.h"
|
||||||
|
|
||||||
#include "../Library/OSRM.h"
|
#include "../Library/OSRM.h"
|
||||||
#include "../Util/SimpleLogger.h"
|
#include "../Util/SimpleLogger.h"
|
||||||
#include "../Util/StringUtil.h"
|
#include "../Util/StringUtil.h"
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
|
||||||
|
#include <osrm/Reply.h>
|
||||||
#include <osrm/RouteParameters.h>
|
#include <osrm/RouteParameters.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
@ -28,10 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifndef REQUEST_HANDLER_H
|
#ifndef REQUEST_HANDLER_H
|
||||||
#define REQUEST_HANDLER_H
|
#define REQUEST_HANDLER_H
|
||||||
|
|
||||||
#include "Http/Request.h"
|
|
||||||
|
|
||||||
#include <osrm/Reply.h>
|
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -41,6 +37,11 @@ struct APIGrammar;
|
|||||||
struct RouteParameters;
|
struct RouteParameters;
|
||||||
class OSRM;
|
class OSRM;
|
||||||
|
|
||||||
|
namespace http {
|
||||||
|
class Reply;
|
||||||
|
struct Request;
|
||||||
|
}
|
||||||
|
|
||||||
class RequestHandler : private boost::noncopyable {
|
class RequestHandler : private boost::noncopyable {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user