osrm-backend/include/contractor/query_edge.hpp

79 lines
2.3 KiB
C++
Raw Normal View History

#ifndef QUERYEDGE_HPP
#define QUERYEDGE_HPP
2016-01-02 11:13:44 -05:00
#include "util/typedefs.hpp"
#include <tuple>
2016-01-05 10:51:13 -05:00
namespace osrm
{
namespace contractor
{
2014-05-07 12:39:16 -04:00
struct QueryEdge
{
NodeID source;
NodeID target;
2014-05-07 12:39:16 -04:00
struct EdgeData
{
explicit EdgeData()
2017-03-10 04:57:07 -05:00
: turn_id(0), shortcut(false), weight(0), duration(0), forward(false), backward(false)
{
}
EdgeData(const NodeID turn_id,
const bool shortcut,
const EdgeWeight weight,
const EdgeWeight duration,
const bool forward,
const bool backward)
: turn_id(turn_id), shortcut(shortcut), weight(weight), duration(duration),
forward(forward), backward(backward)
{
}
template <class OtherT> EdgeData(const OtherT &other)
{
weight = other.weight;
duration = other.duration;
shortcut = other.shortcut;
2017-03-10 04:57:07 -05:00
turn_id = other.id;
forward = other.forward;
backward = other.backward;
}
// this ID is either the middle node of the shortcut, or the ID of the edge based node (node
// based edge) storing the appropriate data. If `shortcut` is set to true, we get the middle
// node. Otherwise we see the edge based node to access node data.
2017-03-10 04:57:07 -05:00
NodeID turn_id : 31;
2014-05-07 12:39:16 -04:00
bool shortcut : 1;
EdgeWeight weight;
EdgeWeight duration : 30;
std::uint32_t forward : 1;
std::uint32_t backward : 1;
} data;
2013-08-13 12:35:54 -04:00
QueryEdge() : source(SPECIAL_NODEID), target(SPECIAL_NODEID) {}
QueryEdge(NodeID source, NodeID target, EdgeData data)
: source(source), target(target), data(std::move(data))
{
}
bool operator<(const QueryEdge &rhs) const
2014-05-07 12:39:16 -04:00
{
return std::tie(source, target) < std::tie(rhs.source, rhs.target);
}
2014-05-07 12:39:16 -04:00
bool operator==(const QueryEdge &right) const
{
return (source == right.source && target == right.target &&
data.weight == right.data.weight && data.duration == right.data.duration &&
data.shortcut == right.data.shortcut && data.forward == right.data.forward &&
2017-03-10 04:57:07 -05:00
data.backward == right.data.backward && data.turn_id == right.data.turn_id);
}
};
2016-01-05 10:51:13 -05:00
}
}
#endif // QUERYEDGE_HPP