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.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
19 // A temporary storage for edges imported from Vissim
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
25 #include <vector>
26 #include <string>
27 #include <map>
28 #include <netbuild/NBEdge.h>
31 #include "NIVissimAbstractEdge.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class NBNode;
39 class NBDistrictCont;
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
51  : public NIVissimAbstractEdge {
52 public:
54  NIVissimEdge(int id, const std::string& name,
55  const std::string& type,
56  std::vector<double> laneWidths,
57  double zuschlag1,
58  double zuschlag2, double length,
59  const PositionVector& geom,
60  const NIVissimClosedLanesVector& clv);
61 
63  ~NIVissimEdge();
64 
65  void setNodeCluster(int nodeid);
66  void buildGeom();
67 
69  void addIncomingConnection(int id);
70 
72  void addOutgoingConnection(int id);
73 
75  Position getBegin2D() const;
76 
78  Position getEnd2D() const;
79 
81  double getLength() const;
82 
83  void checkDistrictConnectionExistanceAt(double pos);
84 
87 
90  void setSpeed(int lane, int speedDist);
92 
94  const std::vector<NIVissimEdge*>& getToTreatAsSame() const;
95 
96 
100  bool wasWithinAJunction() const {
101  return myAmWithinJunction;
102  }
103 
104  NIVissimEdge* getBestIncoming() const;
105  NIVissimEdge* getBestOutgoing() const;
106 
107  friend class NIVissimNodeDef_Edges;
108  friend class NIVissimNodeDef_Poly;
109 
110 public:
113  static bool dictionary(int id, const std::string& name,
114  const std::string& type, int noLanes, double zuschlag1,
115  double zuschlag2, double length,
116  const PositionVector& geom,
117  const NIVissimClosedLanesVector& clv);
118 
120  static bool dictionary(int id, NIVissimEdge* o);
121 
123  static NIVissimEdge* dictionary(int id);
124 
133  static void buildConnectionClusters();
134 
136  static void dict_buildNBEdges(NBDistrictCont& dc, NBNodeCont& nc,
137  NBEdgeCont& ec, double offset);
138 
139  static void dict_propagateSpeeds();
140 
141  static void dict_checkEdges2Join();
142 
143 
152  static void reportUnsetSpeeds();
153 
154 
155 private:
157  typedef std::vector<NIVissimConnectionCluster*> ConnectionClusters;
158 
159 private:
168  void buildNBEdge(NBDistrictCont& dc, NBNodeCont& nc,
169  NBEdgeCont& ec, double sameNodesOffset);
170 
172  std::pair<NIVissimConnectionCluster*, NBNode*>
173  getFromNode(NBNodeCont& nc, ConnectionClusters& clusters);
174 
176  std::pair<NIVissimConnectionCluster*, NBNode*>
177  getToNode(NBNodeCont& nc, ConnectionClusters& clusters);
178 
180  std::pair<NBNode*, NBNode*> resolveSameNode(NBNodeCont& nc,
181  double offset, NBNode* prevFrom, NBNode* prevTo);
182 
183 // double recheckSpeedPatches();
184 
185  std::vector<NIVissimConnection*> getOutgoingConnected(int lane) const;
186 
187  void propagateSpeed(double speed, std::vector<int> forLanes);
188 
189 
190  void setDistrictSpeed();
191  double getRealSpeed(int distNo);
193  void propagateOwn();
194 
195 
196 
197 private:
198  static NBNode* getNodeSecure(int nodeid, const Position& pos,
199  const std::string& possibleName);
200 
201  std::pair<NBNode*, NBNode*>
204  NBNode* fromNode, NBNode* toNode);
205 
206 private:
212  public:
214  explicit connection_position_sorter(int edgeid);
215 
217  int operator()(int c1id, int c2id) const;
218 
219  private:
221  int myEdgeID;
222 
223  };
224 
225 
231  public:
233  explicit connection_cluster_position_sorter(int edgeid);
234 
237  NIVissimConnectionCluster* cc2) const;
238 
239  private:
241  int myEdgeID;
242 
243  };
244 
245 private:
247  std::string myName;
248 
250  std::string myType;
251 
254  std::vector<double> myLaneWidths;
255 
258 
261 
264 
266  std::vector<int> myIncomingConnections;
267 
269  std::vector<int> myOutgoingConnections;
270 
271  std::vector<double> myDistrictConnections;
272 
273  std::vector<int> myPatchedSpeeds;
274 
275  std::vector<double> myLaneSpeeds;
276 
277  std::vector<NIVissimEdge*> myToTreatAsSame;
278 
281 
282 private:
284  typedef std::map<int, NIVissimEdge*> DictType;
285 
287  static DictType myDict;
288 
290  static int myMaxID;
291 
292  static std::vector<std::string> myLanesWithMissingSpeeds;
293 
294 };
std::vector< NIVissimClosedLaneDef * > NIVissimClosedLanesVector
A container for districts.
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:59
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:57
Represents a single node (junction) during network building.
Definition: NBNode.h:66
std::map< int, NIVissimAbstractEdge * > DictType
int operator()(NIVissimConnectionCluster *cc1, NIVissimConnectionCluster *cc2) const
comparing operation
connection_cluster_position_sorter(int edgeid)
constructor
int operator()(int c1id, int c2id) const
comparing operation
connection_position_sorter(int edgeid)
constructor
A temporary storage for edges imported from Vissim.
Definition: NIVissimEdge.h:51
void checkDistrictConnectionExistanceAt(double pos)
void propagateOwn()
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.
void mergedInto(NIVissimConnectionCluster *old, NIVissimConnectionCluster *act)
void propagateSpeed(double speed, std::vector< int > forLanes)
const std::vector< NIVissimEdge * > & getToTreatAsSame() const
static int myMaxID
The current maximum id; needed for further id assignment.
Definition: NIVissimEdge.h:290
NIVissimClosedLanesVector myClosedLanes
List of lanes closed on this edge.
Definition: NIVissimEdge.h:260
static std::vector< std::string > myLanesWithMissingSpeeds
Definition: NIVissimEdge.h:292
std::string myName
The name of the edge.
Definition: NIVissimEdge.h:247
NIVissimEdge * getBestOutgoing() const
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:280
static DictType myDict
The dictionary.
Definition: NIVissimEdge.h:287
static void reportUnsetSpeeds()
Writes edges with unset speeds to the warnings message log instance.
std::map< int, NIVissimEdge * > DictType
Definition of the dictionary type.
Definition: NIVissimEdge.h:284
double getRealSpeed(int distNo)
std::vector< double > myDistrictConnections
Definition: NIVissimEdge.h:271
NIVissimEdge * getBestIncoming() const
~NIVissimEdge()
Destructor.
void addOutgoingConnection(int id)
Adds a connection where this edge is the source.
std::vector< double > myLaneSpeeds
Definition: NIVissimEdge.h:275
std::vector< NIVissimConnectionCluster * > ConnectionClusters
The definition for a container for connection clusters.
Definition: NIVissimEdge.h:157
double getLength() const
Returns the length of the node.
void addToConnectionCluster(NIVissimConnectionCluster *c)
void setSpeed(int lane, int speedDist)
bool wasWithinAJunction() const
Returns whether this edge was found to be within a junction.
Definition: NIVissimEdge.h:100
std::pair< NIVissimConnectionCluster *, NBNode * > getFromNode(NBNodeCont &nc, ConnectionClusters &clusters)
Returns the origin node.
std::vector< NIVissimEdge * > myToTreatAsSame
Definition: NIVissimEdge.h:277
void removeFromConnectionCluster(NIVissimConnectionCluster *c)
static void dict_checkEdges2Join()
static void buildConnectionClusters()
Clusters connections of each edge.
Position getBegin2D() const
std::vector< NIVissimConnection * > getOutgoingConnected(int lane) const
static void dict_buildNBEdges(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double offset)
Builds NBEdges from the VissimEdges within the dictionary.
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.
void checkUnconnectedLaneSpeeds()
double myZuschlag1
Additional load values for this edge.
Definition: NIVissimEdge.h:257
static void dict_propagateSpeeds()
std::pair< NIVissimConnectionCluster *, NBNode * > getToNode(NBNodeCont &nc, ConnectionClusters &clusters)
Returns the destination node.
std::vector< double > myLaneWidths
Definition: NIVissimEdge.h:254
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.
std::string myType
The type of the edge.
Definition: NIVissimEdge.h:250
void buildNBEdge(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double sameNodesOffset)
Builds the NBEdge from this VissimEdge.
std::vector< int > myOutgoingConnections
List of connections outgoing from this edge.
Definition: NIVissimEdge.h:269
Position getEnd2D() const
Returns the end position of the edge.
void setDistrictSpeed()
bool addToTreatAsSame(NIVissimEdge *e)
int myNoLanes
The number of lanes the edge has.
Definition: NIVissimEdge.h:253
void setNodeCluster(int nodeid)
NIVissimConnection * getConnectionTo(NIVissimEdge *e)
std::vector< int > myPatchedSpeeds
Definition: NIVissimEdge.h:273
static NBNode * getNodeSecure(int nodeid, const Position &pos, const std::string &possibleName)
std::pair< NBNode *, NBNode * > remapOneOfNodes(NBNodeCont &nc, NIVissimDistrictConnection *d, NBNode *fromNode, NBNode *toNode)
ConnectionClusters myConnectionClusters
List of connection clusters along this edge.
Definition: NIVissimEdge.h:263
double myZuschlag2
Definition: NIVissimEdge.h:257
std::vector< int > myIncomingConnections
List of connections incoming to this edge.
Definition: NIVissimEdge.h:266
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.