Eclipse SUMO - Simulation of Urban MObility
GNELane2laneConnection.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 #include <utils/geom/GeomHelper.h>
21 
25 
26 #include "GNELane2laneConnection.h"
27 
28 
29 // ===========================================================================
30 // method definitions
31 // ===========================================================================
32 
34  myFromLane(fromLane) {
35 }
36 
37 
38 void
40  // declare numPoints
41  const int numPoints = 5;
42  const int maximumLanes = 10;
43  // clear connectionsMap
44  myConnectionsMap.clear();
45  // iterate over outgoingEdge's lanes
46  for (const auto& outgoingEdge : myFromLane->getParentEdge()->getToJunction()->getGNEOutgoingEdges()) {
47  for (const auto& outgoingLane : outgoingEdge->getLanes()) {
48  // get NBEdges from and to
49  const NBEdge* NBEdgeFrom = myFromLane->getParentEdge()->getNBEdge();
50  const NBEdge* NBEdgeTo = outgoingLane->getParentEdge()->getNBEdge();
51  // declare shape
52  PositionVector shape;
53  // only create smooth shapes if Edge From has as maximum 10 lanes
54  if ((NBEdgeFrom->getNumLanes() <= maximumLanes) && (NBEdgeFrom->getToNode()->getShape().area() > 4)) {
55  // calculate smoot shape
56  shape = NBEdgeFrom->getToNode()->computeSmoothShape(
57  NBEdgeFrom->getLaneShape(myFromLane->getIndex()),
58  NBEdgeTo->getLaneShape(outgoingLane->getIndex()),
59  numPoints, NBEdgeFrom->getTurnDestination() == NBEdgeTo,
60  (double) numPoints * (double) NBEdgeFrom->getNumLanes(),
61  (double) numPoints * (double) NBEdgeTo->getNumLanes());
62  } else {
63  // create a shape using lane shape extremes
64  shape = {myFromLane->getLaneShape().back(), outgoingLane->getLaneShape().front()};
65  }
66  // update connection map
67  myConnectionsMap[outgoingLane].updateGeometry(shape);
68  }
69  }
70 }
71 
72 
73 bool
74 GNELane2laneConnection::exist(const GNELane* toLane) const {
75  return (myConnectionsMap.count(toLane) > 0);
76 }
77 
78 
79 const GUIGeometry&
81  return myConnectionsMap.at(toLane);
82 }
83 
84 
86  myFromLane(nullptr) {
87 }
88 
89 /****************************************************************************/
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:435
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:131
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:797
GNEEdge * getParentEdge() const
get arent edge
Definition: GNELane.cpp:113
The representation of a single edge during network building.
Definition: NBEdge.h:91
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:541
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:515
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition: NBEdge.cpp:3684
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
Definition: NBEdge.cpp:930
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:514
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:2418
A list of positions.
double area() const
Returns the area (0 for non-closed)