Eclipse 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-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 /****************************************************************************/
16 // A temporary storage for edges imported from Vissim
17 /****************************************************************************/
18 #ifndef NIVissimEdge_h
19 #define NIVissimEdge_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
28 #include <vector>
29 #include <string>
30 #include <map>
31 #include <netbuild/NBEdge.h>
34 #include "NIVissimAbstractEdge.h"
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class NBNode;
42 class NBDistrictCont;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
54  : public NIVissimAbstractEdge {
55 public:
57  NIVissimEdge(int id, const std::string& name,
58  const std::string& type,
59  std::vector<double> laneWidths,
60  double zuschlag1,
61  double zuschlag2, double length,
62  const PositionVector& geom,
63  const NIVissimClosedLanesVector& clv);
64 
66  ~NIVissimEdge();
67 
68  void setNodeCluster(int nodeid);
69  void buildGeom();
70 
72  void addIncomingConnection(int id);
73 
75  void addOutgoingConnection(int id);
76 
79  NBNode* getNodeAt(const Position& p, NBNode* other = 0);
80 
82  Position getBegin2D() const;
83 
85  Position getEnd2D() const;
86 
88  double getLength() const;
89 
90  void checkDistrictConnectionExistanceAt(double pos);
91 
94 
97  void setSpeed(int lane, int speedDist);
99 
101  const std::vector<NIVissimEdge*>& getToTreatAsSame() const;
102 
103 
107  bool wasWithinAJunction() const {
108  return myAmWithinJunction;
109  }
110 
111  NIVissimEdge* getBestIncoming() const;
112  NIVissimEdge* getBestOutgoing() const;
113 
114  friend class NIVissimNodeDef_Edges;
115  friend class NIVissimNodeDef_Poly;
116 
117 public:
120  static bool dictionary(int id, const std::string& name,
121  const std::string& type, int noLanes, double zuschlag1,
122  double zuschlag2, double length,
123  const PositionVector& geom,
124  const NIVissimClosedLanesVector& clv);
125 
127  static bool dictionary(int id, NIVissimEdge* o);
128 
130  static NIVissimEdge* dictionary(int id);
131 
140  static void buildConnectionClusters();
141 
143  static void dict_buildNBEdges(NBDistrictCont& dc, NBNodeCont& nc,
144  NBEdgeCont& ec, double offset);
145 
146  static void dict_propagateSpeeds();
147 
148  static void dict_checkEdges2Join();
149 
150 
159  static void reportUnsetSpeeds();
160 
161 
162 private:
164  typedef std::vector<NIVissimConnectionCluster*> ConnectionClusters;
165 
166 private:
175  void buildNBEdge(NBDistrictCont& dc, NBNodeCont& nc,
176  NBEdgeCont& ec, double sameNodesOffset);
177 
179  std::pair<NIVissimConnectionCluster*, NBNode*>
180  getFromNode(NBNodeCont& nc, ConnectionClusters& clusters);
181 
183  std::pair<NIVissimConnectionCluster*, NBNode*>
184  getToNode(NBNodeCont& nc, ConnectionClusters& clusters);
185 
187  std::pair<NBNode*, NBNode*> resolveSameNode(NBNodeCont& nc,
188  double offset, NBNode* prevFrom, NBNode* prevTo);
189 
190 // double recheckSpeedPatches();
191 
192  std::vector<NIVissimConnection*> getOutgoingConnected(int lane) const;
193 
194  void propagateSpeed(double speed, std::vector<int> forLanes);
195 
196 
197  void setDistrictSpeed();
198  double getRealSpeed(int distNo);
200  void propagateOwn();
201 
202 
203 
204 private:
205  static NBNode* getNodeSecure(int nodeid, const Position& pos,
206  const std::string& possibleName);
207 
208  std::pair<NBNode*, NBNode*>
211  NBNode* fromNode, NBNode* toNode);
212 
213 private:
219  public:
221  explicit connection_position_sorter(int edgeid);
222 
224  int operator()(int c1id, int c2id) const;
225 
226  private:
228  int myEdgeID;
229 
230  };
231 
232 
238  public:
240  explicit connection_cluster_position_sorter(int edgeid);
241 
244  NIVissimConnectionCluster* cc2) const;
245 
246  private:
248  int myEdgeID;
249 
250  };
251 
252 private:
254  std::string myName;
255 
257  std::string myType;
258 
261  std::vector<double> myLaneWidths;
262 
265 
268 
270  ConnectionClusters myConnectionClusters;
271 
273  std::vector<int> myIncomingConnections;
274 
276  std::vector<int> myOutgoingConnections;
277 
278  std::vector<double> myDistrictConnections;
279 
280  std::vector<int> myPatchedSpeeds;
281 
282  std::vector<double> myLaneSpeeds;
283 
284  std::vector<NIVissimEdge*> myToTreatAsSame;
285 
288 
289 private:
291  typedef std::map<int, NIVissimEdge*> DictType;
292 
294  static DictType myDict;
295 
297  static int myMaxID;
298 
299  static std::vector<std::string> myLanesWithMissingSpeeds;
300 
301 };
302 
303 
304 #endif
305 
306 /****************************************************************************/
307 
std::vector< NIVissimConnection * > getOutgoingConnected(int lane) const
static int myMaxID
The current maximum id; needed for further id assignment.
Definition: NIVissimEdge.h:297
std::vector< double > myDistrictConnections
Definition: NIVissimEdge.h:278
~NIVissimEdge()
Destructor.
std::string myName
The name of the edge.
Definition: NIVissimEdge.h:254
static void dict_checkEdges2Join()
std::map< int, NIVissimEdge * > DictType
Definition of the dictionary type.
Definition: NIVissimEdge.h:291
std::vector< int > myPatchedSpeeds
Definition: NIVissimEdge.h:280
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:270
std::vector< double > myLaneSpeeds
Definition: NIVissimEdge.h:282
double myZuschlag2
Definition: NIVissimEdge.h:264
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:53
NIVissimEdge(int id, const std::string &name, const std::string &type, std::vector< double > laneWidths, double zuschlag1, double zuschlag2, double length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Constructor.
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:260
double myZuschlag1
Additional load values for this edge.
Definition: NIVissimEdge.h:264
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:287
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:39
A list of positions.
std::vector< int > myIncomingConnections
List of connections incoming to this edge.
Definition: NIVissimEdge.h:273
double getLength() const
Returns the length of the node.
void checkDistrictConnectionExistanceAt(double pos)
std::string myType
The type of the edge.
Definition: NIVissimEdge.h:257
void setDistrictSpeed()
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:61
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.
std::vector< double > myLaneWidths
Definition: NIVissimEdge.h:261
static void buildConnectionClusters()
Clusters connections of each edge.
std::vector< NIVissimEdge * > myToTreatAsSame
Definition: NIVissimEdge.h:284
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:107
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:299
NIVissimClosedLanesVector myClosedLanes
List of lanes closed on this edge.
Definition: NIVissimEdge.h:267
std::vector< NIVissimConnectionCluster * > ConnectionClusters
The definition for a container for connection clusters.
Definition: NIVissimEdge.h:164
Represents a single node (junction) during network building.
Definition: NBNode.h:68
void propagateOwn()
static DictType myDict
The dictionary.
Definition: NIVissimEdge.h:294
const std::vector< NIVissimEdge * > & getToTreatAsSame() const
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:60
void mergedInto(NIVissimConnectionCluster *old, NIVissimConnectionCluster *act)
std::vector< int > myOutgoingConnections
List of connections outgoing from this edge.
Definition: NIVissimEdge.h:276
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)