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-2018 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, int noLanes, double zuschlag1,
59  double zuschlag2, double length,
60  const PositionVector& geom,
61  const NIVissimClosedLanesVector& clv);
62 
64  ~NIVissimEdge();
65 
66  void setNodeCluster(int nodeid);
67  void buildGeom();
68 
70  void addIncomingConnection(int id);
71 
73  void addOutgoingConnection(int id);
74 
77  NBNode* getNodeAt(const Position& p, NBNode* other = 0);
78 
80  Position getBegin2D() const;
81 
83  Position getEnd2D() const;
84 
86  double getLength() const;
87 
88  void checkDistrictConnectionExistanceAt(double pos);
89 
92 
95  void setSpeed(int lane, int speedDist);
97 
99  const std::vector<NIVissimEdge*>& getToTreatAsSame() const;
100 
101 
105  bool wasWithinAJunction() const {
106  return myAmWithinJunction;
107  }
108 
109  NIVissimEdge* getBestIncoming() const;
110  NIVissimEdge* getBestOutgoing() const;
111 
112  friend class NIVissimNodeDef_Edges;
113  friend class NIVissimNodeDef_Poly;
114 
115 public:
118  static bool dictionary(int id, const std::string& name,
119  const std::string& type, int noLanes, double zuschlag1,
120  double zuschlag2, double length,
121  const PositionVector& geom,
122  const NIVissimClosedLanesVector& clv);
123 
125  static bool dictionary(int id, NIVissimEdge* o);
126 
128  static NIVissimEdge* dictionary(int id);
129 
138  static void buildConnectionClusters();
139 
141  static void dict_buildNBEdges(NBDistrictCont& dc, NBNodeCont& nc,
142  NBEdgeCont& ec, double offset);
143 
144  static void dict_propagateSpeeds();
145 
146  static void dict_checkEdges2Join();
147 
148 
157  static void reportUnsetSpeeds();
158 
159 
160 private:
162  typedef std::vector<NIVissimConnectionCluster*> ConnectionClusters;
163 
164 private:
173  void buildNBEdge(NBDistrictCont& dc, NBNodeCont& nc,
174  NBEdgeCont& ec, double sameNodesOffset);
175 
177  std::pair<NIVissimConnectionCluster*, NBNode*>
178  getFromNode(NBNodeCont& nc, ConnectionClusters& clusters);
179 
181  std::pair<NIVissimConnectionCluster*, NBNode*>
182  getToNode(NBNodeCont& nc, ConnectionClusters& clusters);
183 
185  std::pair<NBNode*, NBNode*> resolveSameNode(NBNodeCont& nc,
186  double offset, NBNode* prevFrom, NBNode* prevTo);
187 
188 // double recheckSpeedPatches();
189 
190  std::vector<NIVissimConnection*> getOutgoingConnected(int lane) const;
191 
192  void propagateSpeed(double speed, std::vector<int> forLanes);
193 
194 
195  void setDistrictSpeed();
196  double getRealSpeed(int distNo);
198  void propagateOwn();
199 
200 
201 
202 private:
203  static NBNode* getNodeSecure(int nodeid, const Position& pos,
204  const std::string& possibleName);
205 
206  std::pair<NBNode*, NBNode*>
209  NBNode* fromNode, NBNode* toNode);
210 
211 private:
217  public:
219  explicit connection_position_sorter(int edgeid);
220 
222  int operator()(int c1id, int c2id) const;
223 
224  private:
226  int myEdgeID;
227 
228  };
229 
230 
236  public:
238  explicit connection_cluster_position_sorter(int edgeid);
239 
242  NIVissimConnectionCluster* cc2) const;
243 
244  private:
246  int myEdgeID;
247 
248  };
249 
250 private:
252  std::string myName;
253 
255  std::string myType;
256 
259 
262 
265 
267  ConnectionClusters myConnectionClusters;
268 
270  std::vector<int> myIncomingConnections;
271 
273  std::vector<int> myOutgoingConnections;
274 
275  std::vector<double> myDistrictConnections;
276 
277  std::vector<int> myPatchedSpeeds;
278 
279  std::vector<double> myLaneSpeeds;
280 
281  std::vector<NIVissimEdge*> myToTreatAsSame;
282 
285 
286 private:
288  typedef std::map<int, NIVissimEdge*> DictType;
289 
291  static DictType myDict;
292 
294  static int myMaxID;
295 
296  static std::vector<std::string> myLanesWithMissingSpeeds;
297 
298 };
299 
300 
301 #endif
302 
303 /****************************************************************************/
304 
std::vector< NIVissimConnection * > getOutgoingConnected(int lane) const
static int myMaxID
The current maximum id; needed for further id assignment.
Definition: NIVissimEdge.h:294
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:275
~NIVissimEdge()
Destructor.
std::string myName
The name of the edge.
Definition: NIVissimEdge.h:252
static void dict_checkEdges2Join()
std::map< int, NIVissimEdge * > DictType
Definition of the dictionary type.
Definition: NIVissimEdge.h:288
std::vector< int > myPatchedSpeeds
Definition: NIVissimEdge.h:277
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:267
std::vector< double > myLaneSpeeds
Definition: NIVissimEdge.h:279
double myZuschlag2
Definition: NIVissimEdge.h:261
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
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:258
double myZuschlag1
Additional load values for this edge.
Definition: NIVissimEdge.h:261
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:284
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:270
double getLength() const
Returns the length of the node.
void checkDistrictConnectionExistanceAt(double pos)
std::string myType
The type of the edge.
Definition: NIVissimEdge.h:255
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.
static void buildConnectionClusters()
Clusters connections of each edge.
std::vector< NIVissimEdge * > myToTreatAsSame
Definition: NIVissimEdge.h:281
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:105
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:296
NIVissimClosedLanesVector myClosedLanes
List of lanes closed on this edge.
Definition: NIVissimEdge.h:264
std::vector< NIVissimConnectionCluster * > ConnectionClusters
The definition for a container for connection clusters.
Definition: NIVissimEdge.h:162
Represents a single node (junction) during network building.
Definition: NBNode.h:68
void propagateOwn()
static DictType myDict
The dictionary.
Definition: NIVissimEdge.h:291
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:273
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)