55#pragma GCC diagnostic push
56#pragma GCC diagnostic ignored "-Wunused-parameter"
60#pragma warning(disable: 4267 4458)
68#pragma GCC diagnostic pop
96template<
class E,
class V>
112 explicit CCHGraph(
const std::vector<E*>& allEdges) {
114 unsigned maxNumID = 0;
115 for (
const E* e : allEdges) {
116 maxNumID =
MAX2(maxNumID, (
unsigned)e->getNumericalID());
119 for (
const E* e : allEdges) {
137 std::vector<float> lon(nNodes);
138 std::vector<float> lat(nNodes);
139 for (
unsigned n = 0; n < nNodes; n++) {
142 if (!e->getLanes().empty()) {
143 p = e->getLanes()[0]->geometryPositionAtOffset(e->getLength() * 0.5);
145 const auto* j = e->getToJunction() !=
nullptr ? e->getToJunction() : e->getFromJunction();
146 p = (j !=
nullptr) ? j->getPosition() :
Position(0., 0.);
151 lon[n] = (float)p.
x();
152 lat[n] = (float)p.
y();
154 for (
unsigned n = 0; n < nNodes; n++) {
156 for (
const auto& follower : u->getViaSuccessors(
SVC_IGNORING)) {
157 const E* to = follower.first;
158 if (to ==
nullptr || to->getNumericalID() >= (int)
myEdgeToNode.size()) {
161 const unsigned toNode =
myEdgeToNode[to->getNumericalID()];
168 myArcVia.push_back(follower.second);
178 for (
unsigned a = 0; a < (unsigned)
myArcHead.size(); a++) {
181 while (via !=
nullptr && via->isInternal()) {
182 if (via->getNumericalID() >= 0 && via->getNumericalID() < (int)
myEdgeToArcs.size()) {
185 const auto& vs = via->getViaSuccessors();
186 via = vs.empty() ? nullptr : vs.front().second;
192 for (
const E* e : allEdges) {
196 std::vector<unsigned> srcNodes;
197 for (
const auto& follower : e->getViaSuccessors(
SVC_IGNORING)) {
198 const unsigned m =
nodeOf(follower.first);
200 srcNodes.push_back(m);
203 std::vector<unsigned> snkNodes;
204 for (
const E* pred : e->getPredecessors()) {
205 const unsigned m =
nodeOf(pred);
207 snkNodes.push_back(m);
210 if (!srcNodes.empty()) {
213 if (!snkNodes.empty()) {
224 std::cout <<
"CCH: " << nNodes <<
" road nodes, "
251 if (e ==
nullptr || e->getNumericalID() < 0 || e->getNumericalID() >= (
int)
myEdgeToNode.size()) {
264 const std::vector<unsigned>&
tazSources(
const E* taz)
const {
265 static const std::vector<unsigned> empty;
272 const std::vector<unsigned>&
tazSinks(
const E* taz)
const {
273 static const std::vector<unsigned> empty;
282 static const std::vector<unsigned> empty;
283 if (e ==
nullptr || e->getNumericalID() < 0 || e->getNumericalID() >= (
int)
myEdgeToArcs.size()) {
296 std::vector<const E*>& into)
const {
297 into.reserve(into.size() + nodePath.size());
298 for (
unsigned node : nodePath) {
306 const V* veh,
double time) {
308 while (via !=
nullptr && via->isInternal()) {
309 sum += effort(via, veh, time);
310 const auto& vs = via->getViaSuccessors();
311 via = vs.empty() ? nullptr : vs.front().second;
327 const V* veh,
double time)
const {
348 const V* veh,
double time,
349 std::vector<unsigned>&
weight)
const {
352 for (
unsigned a = 0; a <
arcCount(); a++) {
375 return e->isTazConnector() && e->getOtherTazConnector() !=
nullptr;
392 for (
unsigned n = 0; n < (unsigned)
myNodeToEdge.size(); n++) {
393 for (
const auto& follower :
myNodeToEdge[n]->getViaSuccessors(vClass)) {
394 const unsigned toNode =
nodeOf(follower.first);
398 const auto it =
myArcOf.find(std::make_pair(n, toNode));
411 const V* veh,
double time)
const {
415 + effort(to, veh, time);
416 if (!(eff < bigEffort)) {
419 const long long cs = std::llround(eff * 100.0);
434 std::map<std::pair<unsigned, unsigned>,
unsigned>
myArcOf;
456template<
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