Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNELane2laneConnection.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// File for lane2lane geometry classes and functions
19/****************************************************************************/
20
24
26
27
28// ===========================================================================
29// method definitions
30// ===========================================================================
31
33 myFromLane(fromLane) {
34}
35
36
37void
39 // declare numPoints
40 const int numPoints = 5;
41 const int maximumLanes = 10;
42 // clear connectionsMap
43 myConnectionsMap.clear();
44 // iterate over outgoingEdge's lanes
45 for (const auto& outgoingEdge : myFromLane->getParentEdge()->getToJunction()->getGNEOutgoingEdges()) {
46 for (const auto& outgoingLane : outgoingEdge->getLanes()) {
47 // get NBEdges from and to
48 const NBEdge* NBEdgeFrom = myFromLane->getParentEdge()->getNBEdge();
49 const NBEdge* NBEdgeTo = outgoingLane->getParentEdge()->getNBEdge();
50 // declare shape
51 PositionVector shape;
52 // only create smooth shapes if Edge From has as maximum 10 lanes
53 if ((NBEdgeFrom->getNumLanes() <= maximumLanes) && (NBEdgeFrom->getToNode()->getShape().area() > 4)) {
54 // calculate smooth shape
55 shape = NBEdgeFrom->getToNode()->computeSmoothShape(
56 NBEdgeFrom->getLaneShape(myFromLane->getIndex()),
57 NBEdgeTo->getLaneShape(outgoingLane->getIndex()),
58 numPoints, NBEdgeFrom->getTurnDestination() == NBEdgeTo,
59 (double) numPoints * (double) NBEdgeFrom->getNumLanes(),
60 (double) numPoints * (double) NBEdgeTo->getNumLanes());
61 } else {
62 // create a shape using lane shape extremes
63 shape = {myFromLane->getLaneShape().back(), outgoingLane->getLaneShape().front()};
64 }
65 // update connection map
66 myConnectionsMap[outgoingLane].updateGeometry(shape);
67 }
68 }
69}
70
71
72bool
74 return (myConnectionsMap.count(toLane) > 0);
75}
76
77
78const GUIGeometry&
80 return myConnectionsMap.at(toLane);
81}
82
83
85 myFromLane(nullptr) {
86}
87
88/****************************************************************************/
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:781
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:82
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given toLane
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
const GNELane * myFromLane
from lane
std::map< const GNELane *, GUIGeometry > myConnectionsMap
connection shape
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:214
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:620
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:196
The representation of a single edge during network building.
Definition NBEdge.h:92
NBNode * getToNode() const
Returns the destination node of the edge.
Definition NBEdge.h:546
int getNumLanes() const
Returns the number of lanes.
Definition NBEdge.h:520
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition NBEdge.cpp:4008
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
Definition NBEdge.cpp:986
PositionVector computeSmoothShape(const PositionVector &begShape, const PositionVector &endShape, int numPoints, bool isTurnaround, double extrapolateBeg, double extrapolateEnd, NBNode *recordError=0, int shapeFlag=0) const
Compute a smooth curve between the given geometries.
Definition NBNode.cpp:545
const PositionVector & getShape() const
retrieve the junction shape
Definition NBNode.cpp:2667
A list of positions.
double area() const
Returns the area (0 for non-closed)