54#pragma GCC diagnostic push
55#pragma GCC diagnostic ignored "-Wunused-parameter"
58#pragma GCC diagnostic pop
85template<
class E,
class V>
101 explicit CCHGraph(
const std::vector<E*>& allEdges) {
103 unsigned maxNumID = 0;
104 for (
const E* e : allEdges) {
105 maxNumID =
MAX2(maxNumID, (
unsigned)e->getNumericalID());
108 for (
const E* e : allEdges) {
126 std::vector<float> lon(nNodes);
127 std::vector<float> lat(nNodes);
128 for (
unsigned n = 0; n < nNodes; n++) {
131 if (!e->getLanes().empty()) {
132 p = e->getLanes()[0]->geometryPositionAtOffset(e->getLength() * 0.5);
134 const auto* j = e->getToJunction() !=
nullptr ? e->getToJunction() : e->getFromJunction();
135 p = (j !=
nullptr) ? j->getPosition() :
Position(0., 0.);
140 lon[n] = (float)p.
x();
141 lat[n] = (float)p.
y();
143 for (
unsigned n = 0; n < nNodes; n++) {
145 for (
const auto& follower : u->getViaSuccessors(
SVC_IGNORING)) {
146 const E* to = follower.first;
147 if (to ==
nullptr || to->getNumericalID() >= (int)
myEdgeToNode.size()) {
150 const unsigned toNode =
myEdgeToNode[to->getNumericalID()];
157 myArcVia.push_back(follower.second);
167 for (
unsigned a = 0; a < (unsigned)
myArcHead.size(); a++) {
170 while (via !=
nullptr && via->isInternal()) {
171 if (via->getNumericalID() >= 0 && via->getNumericalID() < (int)
myEdgeToArcs.size()) {
174 const auto& vs = via->getViaSuccessors();
175 via = vs.empty() ? nullptr : vs.front().second;
181 unsigned nTazSrc = 0, nTazSnk = 0;
182 for (
const E* e : allEdges) {
186 std::vector<unsigned> srcNodes;
187 for (
const auto& follower : e->getViaSuccessors(
SVC_IGNORING)) {
188 const unsigned m =
nodeOf(follower.first);
190 srcNodes.push_back(m);
193 std::vector<unsigned> snkNodes;
194 for (
const E* pred : e->getPredecessors()) {
195 const unsigned m =
nodeOf(pred);
197 snkNodes.push_back(m);
200 if (!srcNodes.empty()) {
204 if (!snkNodes.empty()) {
216 std::cout <<
"CCH: " << nNodes <<
" road nodes, "
219 <<
"), " << nTazSrc<<
" TAZ sources, " << nTazSnk <<
" TAZ sinks." << std::endl;
243 if (e ==
nullptr || e->getNumericalID() < 0 || e->getNumericalID() >= (
int)
myEdgeToNode.size()) {
256 const std::vector<unsigned>&
tazSources(
const E* taz)
const {
257 static const std::vector<unsigned> empty;
264 const std::vector<unsigned>&
tazSinks(
const E* taz)
const {
265 static const std::vector<unsigned> empty;
274 static const std::vector<unsigned> empty;
275 if (e ==
nullptr || e->getNumericalID() < 0 || e->getNumericalID() >= (
int)
myEdgeToArcs.size()) {
288 std::vector<const E*>& into)
const {
289 into.reserve(into.size() + nodePath.size());
290 for (
unsigned node : nodePath) {
298 const V* veh,
double time) {
300 while (via !=
nullptr && via->isInternal()) {
301 sum += effort(via, veh, time);
302 const auto& vs = via->getViaSuccessors();
303 via = vs.empty() ? nullptr : vs.front().second;
319 const V* veh,
double time)
const {
340 const V* veh,
double time,
341 std::vector<unsigned>&
weight)
const {
344 for (
unsigned a = 0; a <
arcCount(); a++) {
367 return e->isTazConnector() && e->getOtherTazConnector() !=
nullptr;
384 for (
unsigned n = 0; n < (unsigned)
myNodeToEdge.size(); n++) {
385 for (
const auto& follower :
myNodeToEdge[n]->getViaSuccessors(vClass)) {
386 const unsigned toNode =
nodeOf(follower.first);
390 const auto it =
myArcOf.find(std::make_pair(n, toNode));
403 const V* veh,
double time)
const {
407 + effort(to, veh, time);
408 if (!(eff < bigEffort)) {
411 const long long cs = std::llround(eff * 100.0);
426 std::map<std::pair<unsigned, unsigned>,
unsigned>
myArcOf;
448template<
class E,
class V>
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
Metric-independent RoutingKit CCH topology over the PURE road graph.
unsigned edgeIdSpace() const
size of the edge numerical-id space the graph was built over (for callers keeping per-edge-id side ar...
static bool isStarConnector(const E *e)
whether the edge is a district star connector (the paired "<taz>-source"/"-sink" phantom edge) as opp...
std::vector< const E * > myArcVia
per-arc leading via/internal edge (nullptr if none) for path re-expansion
SVCPermissions myPrimedClasses
the classes already primed into myArcPerm
std::vector< SVCPermissions > myArcPerm
per-arc CONNECTION-level permission bitmask, accumulated per primed class (see primeClassMask); mutab...
CCHGraph & operator=(const CCHGraph &)=delete
unsigned nodeOf(const E *e) const
RoutingKit node index for an edge, or INVALID_NODE if not a node.
void expandNodePath(const std::vector< unsigned > &nodePath, std::vector< const E * > &into) const
Map a RoutingKit node path back to the edge sequence.
const std::vector< unsigned > & tazSinks(const E *taz) const
road member nodes of a TAZ-sink connector (its exit edges), to seed multi-TARGET queries; empty if ta...
std::vector< const E * > myNodeToEdge
node index -> backing edge
unsigned arcCount() const
number of input arcs (== number of mapped connections)
std::vector< unsigned > myArcHead
double(* EffortOperation)(const E *const, const V *const, double)
effort callback signature, matching SUMOAbstractRouter::Operation
static const unsigned INVALID_NODE
sentinel for "not a routable node"
void primeClassMask(SUMOVehicleClass vClass) const
Record which arcs vClass may traverse in the per-arc CONNECTION-level permission bitmask – exactly th...
std::vector< unsigned > myArcTail
per-arc endpoints
void fillInputWeights(EffortOperation effort, SUMOVehicleClass maskClass, const V *veh, double time, std::vector< unsigned > &weight) const
Fill a centisecond input-weight buffer for one vehicle class.
unsigned computeArcWeightRaw(unsigned a, EffortOperation effort, const V *veh, double time) const
The unmasked weight of one arc: via-chain effort + head-edge effort, rounded to centiseconds and clam...
const std::vector< unsigned > & tazSources(const E *taz) const
road member nodes of a TAZ-source connector (its entry edges), to seed multi-SOURCE queries; empty if...
void invalidateClassMasks() const
Drop every primed connection mask so the next fill re-primes from the CURRENT successor lists.
std::vector< unsigned > myEdgeToNode
edge numerical id -> node index (INVALID_NODE if not a node)
CCHGraph(const std::vector< E * > &allEdges)
Build the union line graph + CCH from the given edges.
std::vector< std::vector< unsigned > > myEdgeToArcs
edge numerical id -> arcs whose weight reads that edge (head + folded via edges); the reverse image o...
const E * edgeOf(unsigned node) const
the edge backing a RoutingKit node
const RoutingKit::CustomizableContractionHierarchy & cch() const
the immutable CCH (share const& across clones)
std::map< const E *, std::vector< unsigned > > myTazSnkNodes
TAZ-sink connector edge -> its exit-edge road node ids.
std::map< std::pair< unsigned, unsigned >, unsigned > myArcOf
(tail node, head node) -> arc index
const std::vector< unsigned > & arcsOfEdge(const E *e) const
the arcs whose weight depends on the given edge (arcs it heads plus arcs whose folded via chain conta...
CCHGraph(const CCHGraph &)=delete
std::map< const E *, std::vector< unsigned > > myTazSrcNodes
TAZ-source connector edge -> its entry-edge road node ids.
RoutingKit::CustomizableContractionHierarchy myCCH
the immutable hierarchy
unsigned computeArcWeight(unsigned a, EffortOperation effort, SUMOVehicleClass maskClass, const V *veh, double time) const
Recompute the input weight of one arc – the exact per-arc body of fillInputWeights (same masking,...
static double viaChainEffort(const E *via, EffortOperation effort, const V *veh, double time)
effort accumulated crossing the internal/via chain that leads from one real edge onto its successor (...
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
double y() const
Returns the y-position.
std::vector< unsigned > compute_nested_node_dissection_order_using_inertial_flow(unsigned node_count, const std::vector< unsigned > &tail, const std::vector< unsigned > &head, const std::vector< float > &latitude, const std::vector< float > &longitude, const std::function< void(const std::string &)> &log_message=[](const std::string &){})
const unsigned invalid_id
const unsigned inf_weight
unsigned cch_arc_count() const