Skip to content

Commit 02545e4

Browse files
committed
Better handling of nlanes
1 parent 99cdedb commit 02545e4

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/dsf/mobility/RoadNetwork.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,25 @@ namespace dsf::mobility {
507507
auto const& pNode{pair.second};
508508
auto const& inNeighbours{pNode->ingoingEdges()};
509509
auto const& outNeighbours{pNode->outgoingEdges()};
510+
double maxEstimatedFlow{0.0};
511+
std::for_each(inNeighbours.cbegin(),
512+
inNeighbours.cend(),
513+
[this, &maxEstimatedFlow](auto const& edgeId) {
514+
auto const& pStreet{this->edge(edgeId)};
515+
auto const estFlow{pStreet->maxSpeed() * pStreet->nLanes()};
516+
maxEstimatedFlow = std::max(maxEstimatedFlow, estFlow);
517+
});
518+
std::for_each(outNeighbours.cbegin(),
519+
outNeighbours.cend(),
520+
[this, &maxEstimatedFlow](auto const& edgeId) {
521+
auto const& pStreet{this->edge(edgeId)};
522+
auto const estFlow{pStreet->maxSpeed() * pStreet->nLanes()};
523+
maxEstimatedFlow = std::max(maxEstimatedFlow, estFlow);
524+
});
510525
std::for_each(
511526
inNeighbours.cbegin(),
512527
inNeighbours.cend(),
513-
[this, &pNode, &outNeighbours](auto const& edgeId) {
528+
[this, &pNode, &outNeighbours, &maxEstimatedFlow](auto const& edgeId) {
514529
auto const& pInStreet{this->edge(edgeId)};
515530
auto const nLanes{pInStreet->nLanes()};
516531
if (nLanes == 1) {
@@ -520,7 +535,7 @@ namespace dsf::mobility {
520535
std::for_each(
521536
outNeighbours.cbegin(),
522537
outNeighbours.cend(),
523-
[this, &pInStreet, &allowedTurns](auto const& edgeId) {
538+
[this, &pInStreet, &allowedTurns, &maxEstimatedFlow](auto const& edgeId) {
524539
auto const& pOutStreet{this->edge(edgeId)};
525540
if (pOutStreet->target() == pInStreet->source() ||
526541
pInStreet->forbiddenTurns().contains(pOutStreet->id())) {
@@ -533,7 +548,11 @@ namespace dsf::mobility {
533548
return;
534549
}
535550
// Actually going straight means remain on the same road, thus...
536-
if ((pInStreet->priority() == outOppositeStreet->get()->priority()) &&
551+
auto const inEstFlow{pInStreet->maxSpeed() * pInStreet->nLanes()};
552+
auto const outEstFlow{outOppositeStreet->maxSpeed() *
553+
outOppositeStreet->nLanes()};
554+
if (((inEstFlow == maxEstimatedFlow) ==
555+
(outEstFlow == maxEstimatedFlow)) &&
537556
!allowedTurns.contains(Direction::STRAIGHT)) {
538557
spdlog::debug("Street {} prioritized STRAIGHT", pInStreet->id());
539558
if (allowedTurns.contains(Direction::STRAIGHT) &&

0 commit comments

Comments
 (0)