std::pair<NBEdge*, NBEdge*> NBOwnTLDef::getBestCombination(const EdgeVector& edges) { std::pair<NBEdge*, NBEdge*> bestPair(static_cast<NBEdge*>(0), static_cast<NBEdge*>(0)); SUMOReal bestValue = -1; for (EdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) { for (EdgeVector::const_iterator j = i + 1; j != edges.end(); ++j) { const SUMOReal value = computeUnblockedWeightedStreamNumber(*i, *j); if (value > bestValue) { bestValue = value; bestPair = std::pair<NBEdge*, NBEdge*>(*i, *j); } else if (value == bestValue) { const SUMOReal ca = GeomHelper::getMinAngleDiff((*i)->getAngleAtNode((*i)->getToNode()), (*j)->getAngleAtNode((*j)->getToNode())); const SUMOReal oa = GeomHelper::getMinAngleDiff(bestPair.first->getAngleAtNode(bestPair.first->getToNode()), bestPair.second->getAngleAtNode(bestPair.second->getToNode())); if (fabs(oa - ca) < NUMERICAL_EPS) { // break ties by id if (bestPair.first->getID() < (*i)->getID()) { bestPair = std::pair<NBEdge*, NBEdge*>(*i, *j); } } else if (oa < ca) { bestPair = std::pair<NBEdge*, NBEdge*>(*i, *j); } } } } return bestPair; }
std::pair<NBEdge*, NBEdge*> NBOwnTLDef::getBestCombination(const std::vector<NBEdge*> &edges) throw() { std::pair<NBEdge*, NBEdge*> bestPair(static_cast<NBEdge*>(0), static_cast<NBEdge*>(0)); SUMOReal bestValue = -1; for (std::vector<NBEdge*>::const_iterator i=edges.begin(); i!=edges.end(); ++i) { for (std::vector<NBEdge*>::const_iterator j=i+1; j!=edges.end(); ++j) { SUMOReal value = computeUnblockedWeightedStreamNumber(*i, *j); if (value>bestValue) { bestValue = value; bestPair = std::pair<NBEdge*, NBEdge*>(*i, *j); } else if (value==bestValue) { SUMOReal ca = GeomHelper::getMinAngleDiff((*i)->getAngle(*(*i)->getToNode()), (*j)->getAngle(*(*j)->getToNode())); SUMOReal oa = GeomHelper::getMinAngleDiff(bestPair.first->getAngle(*bestPair.first->getToNode()), bestPair.second->getAngle(*bestPair.second->getToNode())); if (oa<ca) { bestPair = std::pair<NBEdge*, NBEdge*>(*i, *j); } } } } return bestPair; }