Eclipse SUMO - Simulation of Urban MObility
NGEdge.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2003-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // A netgen-representation of an edge
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <algorithm>
29 #include <netbuild/NBNode.h>
30 #include <netbuild/NBNodeCont.h>
31 #include <netbuild/NBEdge.h>
32 #include <netbuild/NBOwnTLDef.h>
33 #include <netbuild/NBTypeCont.h>
35 #include <netbuild/NBNetBuilder.h>
37 #include <utils/common/ToString.h>
40 #include <utils/options/Option.h>
41 #include "NGEdge.h"
42 #include "NGNode.h"
43 
44 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
48 // ---------------------------------------------------------------------------
49 // NGEdge-definitions
50 // ---------------------------------------------------------------------------
51 NGEdge::NGEdge(const std::string& id, NGNode* startNode, NGNode* endNode)
52  : Named(id), myStartNode(startNode), myEndNode(endNode) {
53  myStartNode->addLink(this);
54  myEndNode->addLink(this);
55 }
56 
57 
59  myStartNode->removeLink(this);
60  myEndNode->removeLink(this);
61 }
62 
63 
64 NBEdge*
66  int priority = nb.getTypeCont().getPriority("");
67  if (priority > 1 && OptionsCont::getOptions().getBool("rand.random-priority")) {
68  priority = RandHelper::rand(priority) + 1;
69  }
70  int lanenumber = nb.getTypeCont().getNumLanes("");
71  if (lanenumber > 1 && OptionsCont::getOptions().getBool("rand.random-lanenumber")) {
72  lanenumber = RandHelper::rand(lanenumber) + 1;
73  }
74  return new NBEdge(
75  myID,
76  nb.getNodeCont().retrieve(myStartNode->getID()), // from
77  nb.getNodeCont().retrieve(myEndNode->getID()), // to
78  "", nb.getTypeCont().getSpeed(""), lanenumber,
80  );
81 }
82 
83 
84 /****************************************************************************/
85 
NBEdge::UNSPECIFIED_OFFSET
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:306
ToString.h
Named
Base class for objects which have an id.
Definition: Named.h:57
NBNetBuilder
Instance responsible for building networks.
Definition: NBNetBuilder.h:110
OptionsCont.h
NGEdge::buildNBEdge
NBEdge * buildNBEdge(NBNetBuilder &nb) const
Builds and returns this link's netbuild-representation.
Definition: NGEdge.cpp:65
GeoConvHelper.h
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
NGEdge::myStartNode
NGNode * myStartNode
The node the edge starts at.
Definition: NGEdge.h:107
NGNode::removeLink
void removeLink(NGEdge *link)
Removes the given link.
Definition: NGNode.cpp:110
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:86
NGEdge::myEndNode
NGNode * myEndNode
The node the edge ends at.
Definition: NGEdge.h:110
NGNode::addLink
void addLink(NGEdge *link)
Adds the given link to the internal list.
Definition: NGNode.cpp:104
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
NBTypeCont::getSpeed
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:178
NBTypeCont.h
NBNetBuilder.h
UtilExceptions.h
NGEdge::NGEdge
NGEdge(const std::string &id, NGNode *startNode, NGNode *endNode)
Constructor.
Definition: NGEdge.cpp:51
NBTypeCont::getPriority
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:184
NBNodeCont::retrieve
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:108
NBNodeCont.h
Option.h
NBTypeCont::getWidth
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:228
NBTypeCont::getNumLanes
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:172
config.h
RandHelper.h
NBOwnTLDef.h
NBTrafficLightLogicCont.h
NBNetBuilder::getNodeCont
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Definition: NBNetBuilder.h:156
Named::myID
std::string myID
The name of the object.
Definition: Named.h:134
NBNetBuilder::getTypeCont
NBTypeCont & getTypeCont()
Returns a reference to the type container.
Definition: NBNetBuilder.h:161
NBNode.h
NGNode.h
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:77
NGNode
A netgen-representation of a node.
Definition: NGNode.h:51
NGEdge::~NGEdge
~NGEdge()
Destructor.
Definition: NGEdge.cpp:58
NBEdge.h
NGEdge.h