SUMO - Simulation of Urban MObility
NWWriter_SUMO.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 /****************************************************************************/
19 // Exporter writing networks using the SUMO format
20 /****************************************************************************/
21 #ifndef NWWriter_SUMO_h
22 #define NWWriter_SUMO_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <map>
36 #include <netbuild/NBEdge.h>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class OutputDevice;
46 class OptionsCont;
47 class NBNetBuilder;
49 class NBNode;
50 class NBDistrict;
51 class NBEdgeControl;
52 
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
63 public:
64 
66  SUMONET, // all connection information
67  PLAIN, // only edges and link indices
68  TLL // like plain but include tl information
69  };
70 
76  static void writeNetwork(const OptionsCont& oc, NBNetBuilder& nb);
77 
78 
86  static void writeConnection(OutputDevice& into, const NBEdge& from, const NBEdge::Connection& c,
87  bool includeInternal, ConnectionStyle style = SUMONET);
88 
90  static void writeProhibitions(OutputDevice& into, const NBConnectionProhibits& prohibitions);
91 
93  static void writeTrafficLights(OutputDevice& into, const NBTrafficLightLogicCont& tllCont);
94 
100  static void writeRoundabouts(OutputDevice& into, const std::set<EdgeSet>& roundabouts,
101  const NBEdgeCont& ec);
102 
103 private:
106 
112  static bool writeInternalEdges(OutputDevice& into, const NBEdgeCont& ec, const NBNode& n);
113 
114 
121  static void writeEdge(OutputDevice& into, const NBEdge& e, bool noNames);
122 
123 
134  static void writeLane(OutputDevice& into, const std::string& lID,
135  double speed, SVCPermissions permissions, SVCPermissions preferred,
136  double endOffset, double width, PositionVector shape,
137  const Parameterised* params, double length, int index,
138  const std::string& oppositeID, bool accelRamp = false,
139  bool customShape = false);
140 
141 
147  static void writeJunction(OutputDevice& into, const NBNode& n, const bool checkLaneFoes);
148 
149 
154  static bool writeInternalNodes(OutputDevice& into, const NBNode& n);
155 
156 
161  static bool writeInternalConnections(OutputDevice& into, const NBNode& n);
162 
163 
168  static void writeDistrict(OutputDevice& into, const NBDistrict& d);
169 
176  static void writeInternalConnection(OutputDevice& into,
177  const std::string& from, const std::string& to,
178  int fromLane, int toLane, const std::string& via,
180 
182  static std::string writeSUMOTime(SUMOTime time);
183 
184 
186  static std::string prohibitionConnection(const NBConnection& c);
187 
193  static void writeRoundabout(OutputDevice& into, const std::vector<std::string>& r,
194  const NBEdgeCont& ec);
195 
197  static std::string getOppositeInternalID(const NBEdgeCont& ec, const NBEdge* from, const NBEdge::Connection& con);
198 
199 };
200 
201 
202 #endif
203 
204 /****************************************************************************/
205 
static void writeRoundabout(OutputDevice &into, const std::vector< std::string > &r, const NBEdgeCont &ec)
Writes a roundabout.
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:161
static void writeDistrict(OutputDevice &into, const NBDistrict &d)
Writes a district.
static void writeInternalConnection(OutputDevice &into, const std::string &from, const std::string &to, int fromLane, int toLane, const std::string &via, LinkDirection dir=LINKDIR_STRAIGHT)
Writes a single internal connection.
A container for traffic light definitions and built programs.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
The representation of a single edge during network building.
Definition: NBEdge.h:70
static void writeProhibitions(OutputDevice &into, const NBConnectionProhibits &prohibitions)
writes the given prohibitions
static void writeTrafficLights(OutputDevice &into, const NBTrafficLightLogicCont &tllCont)
writes the traffic light logics to the given device
static std::string getOppositeInternalID(const NBEdgeCont &ec, const NBEdge *from, const NBEdge::Connection &con)
retrieve the id of the opposite direction internal lane if it exists
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
The link is a straight direction.
A class representing a single district.
Definition: NBDistrict.h:71
static std::string prohibitionConnection(const NBConnection &c)
the attribute value for a prohibition
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into a SUMO-file.
static bool writeInternalConnections(OutputDevice &into, const NBNode &n)
Writes inner connections within the node.
A list of positions.
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
An upper class for objects with additional parameters.
Definition: Parameterised.h:50
Exporter writing networks using the SUMO format.
Definition: NWWriter_SUMO.h:62
std::map< NBConnection, NBConnectionVector > NBConnectionProhibits
Definition of a container for connection block dependencies Includes a list of all connections which ...
Instance responsible for building networks.
Definition: NBNetBuilder.h:115
static bool writeInternalNodes(OutputDevice &into, const NBNode &n)
Writes internal junctions (<junction with id[0]==&#39;:&#39; ...) of the given node.
static void writeLane(OutputDevice &into, const std::string &lID, double speed, SVCPermissions permissions, SVCPermissions preferred, double endOffset, double width, PositionVector shape, const Parameterised *params, double length, int index, const std::string &oppositeID, bool accelRamp=false, bool customShape=false)
Writes a lane (<lane ...) of an edge.
A storage for options typed value containers)
Definition: OptionsCont.h:98
Represents a single node (junction) during network building.
Definition: NBNode.h:74
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
static void writeJunction(OutputDevice &into, const NBNode &n, const bool checkLaneFoes)
Writes a junction (<junction ...)
long long int SUMOTime
Definition: TraCIDefs.h:51
static bool writeInternalEdges(OutputDevice &into, const NBEdgeCont &ec, const NBNode &n)
Writes internal edges (<edge ... with id[0]==&#39;:&#39;) of the given node.
static void writeEdge(OutputDevice &into, const NBEdge &e, bool noNames)
Writes an edge (<edge ...)
static void writeRoundabouts(OutputDevice &into, const std::set< EdgeSet > &roundabouts, const NBEdgeCont &ec)
Writes roundabouts.
static std::string writeSUMOTime(SUMOTime time)
writes a SUMOTime as int if possible, otherwise as a float
static void writeConnection(OutputDevice &into, const NBEdge &from, const NBEdge::Connection &c, bool includeInternal, ConnectionStyle style=SUMONET)
Writes connections outgoing from the given edge (also used in NWWriter_XML)