SUMO - Simulation of Urban MObility
NIVissimEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
18 // A temporary storage for edges imported from Vissim
19 /****************************************************************************/
20 #ifndef NIVissimEdge_h
21 #define NIVissimEdge_h
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 
34 #include <vector>
35 #include <string>
36 #include <map>
37 #include <netbuild/NBEdge.h>
40 #include "NIVissimAbstractEdge.h"
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class NBNode;
48 class NBDistrictCont;
50 
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
60  : public NIVissimAbstractEdge {
61 public:
63  NIVissimEdge(int id, const std::string& name,
64  const std::string& type, int noLanes, double zuschlag1,
65  double zuschlag2, double length,
66  const PositionVector& geom,
67  const NIVissimClosedLanesVector& clv);
68 
70  ~NIVissimEdge();
71 
72  void setNodeCluster(int nodeid);
73  void buildGeom();
74 
76  void addIncomingConnection(int id);
77 
79  void addOutgoingConnection(int id);
80 
83  NBNode* getNodeAt(const Position& p, NBNode* other = 0);
84 
86  Position getBegin2D() const;
87 
89  Position getEnd2D() const;
90 
92  double getLength() const;
93 
94  void checkDistrictConnectionExistanceAt(double pos);
95 
98 
101  void setSpeed(int lane, int speedDist);
103 
105  const std::vector<NIVissimEdge*>& getToTreatAsSame() const;
106 
107 
111  bool wasWithinAJunction() const {
112  return myAmWithinJunction;
113  }
114 
115  NIVissimEdge* getBestIncoming() const;
116  NIVissimEdge* getBestOutgoing() const;
117 
118  friend class NIVissimNodeDef_Edges;
119  friend class NIVissimNodeDef_Poly;
120 
121 public:
124  static bool dictionary(int id, const std::string& name,
125  const std::string& type, int noLanes, double zuschlag1,
126  double zuschlag2, double length,
127  const PositionVector& geom,
128  const NIVissimClosedLanesVector& clv);
129 
131  static bool dictionary(int id, NIVissimEdge* o);
132 
134  static NIVissimEdge* dictionary(int id);
135 
144  static void buildConnectionClusters();
145 
147  static void dict_buildNBEdges(NBDistrictCont& dc, NBNodeCont& nc,
148  NBEdgeCont& ec, double offset);
149 
150  static void dict_propagateSpeeds();
151 
152  static void dict_checkEdges2Join();
153 
154 
163  static void reportUnsetSpeeds();
164 
165 
166 private:
168  typedef std::vector<NIVissimConnectionCluster*> ConnectionClusters;
169 
170 private:
179  void buildNBEdge(NBDistrictCont& dc, NBNodeCont& nc,
180  NBEdgeCont& ec, double sameNodesOffset);
181 
183  std::pair<NIVissimConnectionCluster*, NBNode*>
184  getFromNode(NBNodeCont& nc, ConnectionClusters& clusters);
185 
187  std::pair<NIVissimConnectionCluster*, NBNode*>
188  getToNode(NBNodeCont& nc, ConnectionClusters& clusters);
189 
191  std::pair<NBNode*, NBNode*> resolveSameNode(NBNodeCont& nc,
192  double offset, NBNode* prevFrom, NBNode* prevTo);
193 
194 // double recheckSpeedPatches();
195 
196  std::vector<NIVissimConnection*> getOutgoingConnected(int lane) const;
197 
198  void propagateSpeed(double speed, std::vector<int> forLanes);
199 
200 
201  void setDistrictSpeed();
202  double getRealSpeed(int distNo);
204  void propagateOwn();
205 
206 
207 
208 private:
209  static NBNode* getNodeSecure(int nodeid, const Position& pos,
210  const std::string& possibleName);
211 
212  std::pair<NBNode*, NBNode*>
215  NBNode* fromNode, NBNode* toNode);
216 
217 private:
223  public:
225  explicit connection_position_sorter(int edgeid);
226 
228  int operator()(int c1id, int c2id) const;
229 
230  private:
232  int myEdgeID;
233 
234  };
235 
236 
242  public:
244  explicit connection_cluster_position_sorter(int edgeid);
245 
248  NIVissimConnectionCluster* cc2) const;
249 
250  private:
252  int myEdgeID;
253 
254  };
255 
256 private:
258  std::string myName;
259 
261  std::string myType;
262 
265 
268 
271 
273  ConnectionClusters myConnectionClusters;
274 
276  std::vector<int> myIncomingConnections;
277 
279  std::vector<int> myOutgoingConnections;
280 
281  std::vector<double> myDistrictConnections;
282 
283  std::vector<int> myPatchedSpeeds;
284 
285  std::vector<double> myLaneSpeeds;
286 
287  std::vector<NIVissimEdge*> myToTreatAsSame;
288 
291 
292 private:
294  typedef std::map<int, NIVissimEdge*> DictType;
295 
297  static DictType myDict;
298 
300  static int myMaxID;
301 
302  static std::vector<std::string> myLanesWithMissingSpeeds;
303 
304 };
305 
306 
307 #endif
308 
309 /****************************************************************************/
310 
std::vector< NIVissimConnection * > getOutgoingConnected(int lane) const
static int myMaxID
The current maximum id; needed for further id assignment.
Definition: NIVissimEdge.h:300
NIVissimEdge(int id, const std::string &name, const std::string &type, int noLanes, double zuschlag1, double zuschlag2, double length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Constructor.
std::vector< double > myDistrictConnections
Definition: NIVissimEdge.h:281
~NIVissimEdge()
Destructor.
std::string myName
The name of the edge.
Definition: NIVissimEdge.h:258
static void dict_checkEdges2Join()
std::map< int, NIVissimEdge * > DictType
Definition of the dictionary type.
Definition: NIVissimEdge.h:294
std::vector< int > myPatchedSpeeds
Definition: NIVissimEdge.h:283
std::pair< NBNode *, NBNode * > remapOneOfNodes(NBNodeCont &nc, NIVissimDistrictConnection *d, NBNode *fromNode, NBNode *toNode)
static void reportUnsetSpeeds()
Writes edges with unset speeds to the warnings message log instance.
std::vector< NIVissimClosedLaneDef * > NIVissimClosedLanesVector
ConnectionClusters myConnectionClusters
List of connection clusters along this edge.
Definition: NIVissimEdge.h:273
std::vector< double > myLaneSpeeds
Definition: NIVissimEdge.h:285
double myZuschlag2
Definition: NIVissimEdge.h:267
A container for districts.
static void dict_buildNBEdges(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double offset)
Builds NBEdges from the VissimEdges within the dictionary.
void addToConnectionCluster(NIVissimConnectionCluster *c)
void setNodeCluster(int nodeid)
NIVissimEdge * getBestIncoming() const
A temporary storage for edges imported from Vissim.
Definition: NIVissimEdge.h:59
Position getBegin2D() const
void propagateSpeed(double speed, std::vector< int > forLanes)
NIVissimEdge * getBestOutgoing() const
int myNoLanes
The number of lanes the edge has.
Definition: NIVissimEdge.h:264
double myZuschlag1
Additional load values for this edge.
Definition: NIVissimEdge.h:267
double getRealSpeed(int distNo)
void setSpeed(int lane, int speedDist)
void addIncomingConnection(int id)
Adds a connection where this edge is the destination.
bool myAmWithinJunction
Information whether this edge was not build due to being within a junction.
Definition: NIVissimEdge.h:290
static void dict_propagateSpeeds()
int operator()(int c1id, int c2id) const
comparing operation
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
std::vector< int > myIncomingConnections
List of connections incoming to this edge.
Definition: NIVissimEdge.h:276
double getLength() const
Returns the length of the node.
void checkDistrictConnectionExistanceAt(double pos)
std::string myType
The type of the edge.
Definition: NIVissimEdge.h:261
void setDistrictSpeed()
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
connection_position_sorter(int edgeid)
constructor
void checkUnconnectedLaneSpeeds()
void addOutgoingConnection(int id)
Adds a connection where this edge is the source.
void buildNBEdge(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double sameNodesOffset)
Builds the NBEdge from this VissimEdge.
NBNode * getNodeAt(const Position &p, NBNode *other=0)
Returns the node at the given position As this may be ambigous, a second node not to return may be su...
static bool dictionary(int id, const std::string &name, const std::string &type, int noLanes, double zuschlag1, double zuschlag2, double length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Adds the described item to the dictionary Builds the edge first.
NIVissimConnection * getConnectionTo(NIVissimEdge *e)
std::pair< NIVissimConnectionCluster *, NBNode * > getToNode(NBNodeCont &nc, ConnectionClusters &clusters)
Returns the destination node.
static void buildConnectionClusters()
Clusters connections of each edge.
std::vector< NIVissimEdge * > myToTreatAsSame
Definition: NIVissimEdge.h:287
bool addToTreatAsSame(NIVissimEdge *e)
Position getEnd2D() const
Returns the end position of the edge.
bool wasWithinAJunction() const
Returns whether this edge was found to be within a junction.
Definition: NIVissimEdge.h:111
std::pair< NBNode *, NBNode * > resolveSameNode(NBNodeCont &nc, double offset, NBNode *prevFrom, NBNode *prevTo)
Tries to resolve the problem that the same node has been returned as origin and destination node...
static std::vector< std::string > myLanesWithMissingSpeeds
Definition: NIVissimEdge.h:302
NIVissimClosedLanesVector myClosedLanes
List of lanes closed on this edge.
Definition: NIVissimEdge.h:270
std::vector< NIVissimConnectionCluster * > ConnectionClusters
The definition for a container for connection clusters.
Definition: NIVissimEdge.h:168
Represents a single node (junction) during network building.
Definition: NBNode.h:74
void propagateOwn()
static DictType myDict
The dictionary.
Definition: NIVissimEdge.h:297
const std::vector< NIVissimEdge * > & getToTreatAsSame() const
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:66
void mergedInto(NIVissimConnectionCluster *old, NIVissimConnectionCluster *act)
std::vector< int > myOutgoingConnections
List of connections outgoing from this edge.
Definition: NIVissimEdge.h:279
std::pair< NIVissimConnectionCluster *, NBNode * > getFromNode(NBNodeCont &nc, ConnectionClusters &clusters)
Returns the origin node.
void removeFromConnectionCluster(NIVissimConnectionCluster *c)
static NBNode * getNodeSecure(int nodeid, const Position &pos, const std::string &possibleName)