/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GNELane2laneConnection.cpp14/// @author Pablo Alvarez Lopez15/// @date Nov 201916///17// File for lane2lane geometry classes and functions18/****************************************************************************/1920#include <netedit/elements/network/GNEEdge.h>21#include <netedit/elements/network/GNELane.h>22#include <netedit/elements/network/GNEJunction.h>2324#include "GNELane2laneConnection.h"2526// ===========================================================================27// method definitions28// ===========================================================================2930GNELane2laneConnection::GNELane2laneConnection(const GNELane* fromLane) :31myFromLane(fromLane) {32}333435void36GNELane2laneConnection::updateLane2laneConnection() {37// declare numPoints38const int numPoints = 5;39const int maximumLanes = 10;40// clear connectionsMap41myConnectionsMap.clear();42// iterate over outgoingEdge's lanes43for (const auto& outgoingEdge : myFromLane->getParentEdge()->getToJunction()->getGNEOutgoingEdges()) {44for (const auto& outgoingLane : outgoingEdge->getChildLanes()) {45// get NBEdges from and to46const NBEdge* NBEdgeFrom = myFromLane->getParentEdge()->getNBEdge();47const NBEdge* NBEdgeTo = outgoingLane->getParentEdge()->getNBEdge();48// declare shape49PositionVector shape;50// only create smooth shapes if Edge From has as maximum 10 lanes51if ((NBEdgeFrom->getNumLanes() <= maximumLanes) && (NBEdgeFrom->getToNode()->getShape().area() > 4)) {52// calculate smooth shape53shape = NBEdgeFrom->getToNode()->computeSmoothShape(54NBEdgeFrom->getLaneShape(myFromLane->getIndex()),55NBEdgeTo->getLaneShape(outgoingLane->getIndex()),56numPoints, NBEdgeFrom->getTurnDestination() == NBEdgeTo,57(double) numPoints * (double) NBEdgeFrom->getNumLanes(),58(double) numPoints * (double) NBEdgeTo->getNumLanes());59} else {60// create a shape using lane shape extremes61shape = {myFromLane->getLaneShape().back(), outgoingLane->getLaneShape().front()};62}63// update connection map64myConnectionsMap[outgoingLane].updateGeometry(shape);65}66}67}686970bool71GNELane2laneConnection::exist(const GNELane* toLane) const {72return (myConnectionsMap.count(toLane) > 0);73}747576const GUIGeometry&77GNELane2laneConnection::getLane2laneGeometry(const GNELane* toLane) const {78return myConnectionsMap.at(toLane);79}808182GNELane2laneConnection::GNELane2laneConnection() :83myFromLane(nullptr) {84}8586/****************************************************************************/878889