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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // A netgen-representation of an edge
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <algorithm>
34 #include <netbuild/NBNode.h>
35 #include <netbuild/NBNodeCont.h>
36 #include <netbuild/NBEdge.h>
37 #include <netbuild/NBOwnTLDef.h>
38 #include <netbuild/NBTypeCont.h>
40 #include <netbuild/NBNetBuilder.h>
42 #include <utils/common/ToString.h>
45 #include <utils/options/Option.h>
46 #include "NGEdge.h"
47 #include "NGNode.h"
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 // ---------------------------------------------------------------------------
54 // NGEdge-definitions
55 // ---------------------------------------------------------------------------
56 NGEdge::NGEdge(const std::string& id, NGNode* startNode, NGNode* endNode)
57  : Named(id), myStartNode(startNode), myEndNode(endNode) {
58  myStartNode->addLink(this);
59  myEndNode->addLink(this);
60 }
61 
62 
64  myStartNode->removeLink(this);
65  myEndNode->removeLink(this);
66 }
67 
68 
69 NBEdge*
71  return new NBEdge(
72  myID,
73  nb.getNodeCont().retrieve(myStartNode->getID()), // from
74  nb.getNodeCont().retrieve(myEndNode->getID()), // to
75  "", nb.getTypeCont().getSpeed(""), nb.getTypeCont().getNumLanes(""),
77  );
78 }
79 
80 
81 /****************************************************************************/
82 
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:108
~NGEdge()
Destructor.
Definition: NGEdge.cpp:63
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:180
NBTypeCont & getTypeCont()
Returns a reference to the type container.
Definition: NBNetBuilder.h:166
NBEdge * buildNBEdge(NBNetBuilder &nb) const
Builds and returns this link&#39;s netbuild-representation.
Definition: NGEdge.cpp:70
The representation of a single edge during network building.
Definition: NBEdge.h:70
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:186
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:257
void removeLink(NGEdge *link)
Removes the given link.
Definition: NGNode.cpp:116
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:174
const std::string & getID() const
Returns the id.
Definition: Named.h:65
NGEdge(const std::string &id, NGNode *startNode, NGNode *endNode)
Constructor.
Definition: NGEdge.cpp:56
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:216
Base class for objects which have an id.
Definition: Named.h:45
std::string myID
The name of the object.
Definition: Named.h:135
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Definition: NBNetBuilder.h:161
NGNode * myEndNode
The node the edge ends at.
Definition: NGEdge.h:116
Instance responsible for building networks.
Definition: NBNetBuilder.h:115
A netgen-representation of a node.
Definition: NGNode.h:57
NGNode * myStartNode
The node the edge starts at.
Definition: NGEdge.h:113
void addLink(NGEdge *link)
Adds the given link to the internal list.
Definition: NGNode.cpp:110