Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/GNELane2laneConnection.cpp
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file GNELane2laneConnection.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Nov 2019
17
///
18
// File for lane2lane geometry classes and functions
19
/****************************************************************************/
20
21
#include <netedit/elements/network/GNEEdge.h>
22
#include <netedit/elements/network/GNELane.h>
23
#include <netedit/elements/network/GNEJunction.h>
24
25
#include "GNELane2laneConnection.h"
26
27
// ===========================================================================
28
// method definitions
29
// ===========================================================================
30
31
GNELane2laneConnection::GNELane2laneConnection(const GNELane* fromLane) :
32
myFromLane(fromLane) {
33
}
34
35
36
void
37
GNELane2laneConnection::updateLane2laneConnection() {
38
// declare numPoints
39
const int numPoints = 5;
40
const int maximumLanes = 10;
41
// clear connectionsMap
42
myConnectionsMap.clear();
43
// iterate over outgoingEdge's lanes
44
for (const auto& outgoingEdge : myFromLane->getParentEdge()->getToJunction()->getGNEOutgoingEdges()) {
45
for (const auto& outgoingLane : outgoingEdge->getChildLanes()) {
46
// get NBEdges from and to
47
const NBEdge* NBEdgeFrom = myFromLane->getParentEdge()->getNBEdge();
48
const NBEdge* NBEdgeTo = outgoingLane->getParentEdge()->getNBEdge();
49
// declare shape
50
PositionVector shape;
51
// only create smooth shapes if Edge From has as maximum 10 lanes
52
if ((NBEdgeFrom->getNumLanes() <= maximumLanes) && (NBEdgeFrom->getToNode()->getShape().area() > 4)) {
53
// calculate smooth shape
54
shape = NBEdgeFrom->getToNode()->computeSmoothShape(
55
NBEdgeFrom->getLaneShape(myFromLane->getIndex()),
56
NBEdgeTo->getLaneShape(outgoingLane->getIndex()),
57
numPoints, NBEdgeFrom->getTurnDestination() == NBEdgeTo,
58
(double) numPoints * (double) NBEdgeFrom->getNumLanes(),
59
(double) numPoints * (double) NBEdgeTo->getNumLanes());
60
} else {
61
// create a shape using lane shape extremes
62
shape = {myFromLane->getLaneShape().back(), outgoingLane->getLaneShape().front()};
63
}
64
// update connection map
65
myConnectionsMap[outgoingLane].updateGeometry(shape);
66
}
67
}
68
}
69
70
71
bool
72
GNELane2laneConnection::exist(const GNELane* toLane) const {
73
return (myConnectionsMap.count(toLane) > 0);
74
}
75
76
77
const GUIGeometry&
78
GNELane2laneConnection::getLane2laneGeometry(const GNELane* toLane) const {
79
return myConnectionsMap.at(toLane);
80
}
81
82
83
GNELane2laneConnection::GNELane2laneConnection() :
84
myFromLane(nullptr) {
85
}
86
87
/****************************************************************************/
88
89