SUMO - Simulation of Urban MObility
NWWriter_SUMO.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Exporter writing networks using the SUMO format
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NWWriter_SUMO_h
23 #define NWWriter_SUMO_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <map>
37 #include <netbuild/NBEdge.h>
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class OutputDevice;
47 class OptionsCont;
48 class NBNetBuilder;
50 class NBNode;
51 class NBDistrict;
52 class NBEdgeControl;
53 
54 
55 // ===========================================================================
56 // class definitions
57 // ===========================================================================
64 public:
65 
67  SUMONET, // all connection information
68  PLAIN, // only edges and link indices
69  TLL // like plain but include tl information
70  };
71 
77  static void writeNetwork(const OptionsCont& oc, NBNetBuilder& nb);
78 
79 
87  static void writeConnection(OutputDevice& into, const NBEdge& from, const NBEdge::Connection& c,
88  bool includeInternal, ConnectionStyle style = SUMONET);
89 
91  static void writeProhibitions(OutputDevice& into, const NBConnectionProhibits& prohibitions);
92 
94  static void writeTrafficLights(OutputDevice& into, const NBTrafficLightLogicCont& tllCont);
95 
101  static void writeRoundabouts(OutputDevice& into, const std::set<EdgeSet>& roundabouts,
102  const NBEdgeCont& ec);
103 
104 protected:
107 
114  static bool writeInternalEdges(OutputDevice& into, const NBEdgeCont& ec, const NBNode& n, bool origNames);
115 
116 
124  static void writeEdge(OutputDevice& into, const NBEdge& e, bool noNames, bool origNames);
125 
126 
137  static void writeLane(OutputDevice& into, const std::string& lID,
138  SUMOReal speed, SVCPermissions permissions, SVCPermissions preferred,
139  SUMOReal endOffset, SUMOReal width, PositionVector shape,
140  const std::string& origID, SUMOReal length, int index, bool origNames,
141  const std::string& oppositeID, const NBNode* node = 0);
142 
143 
149  static void writeJunction(OutputDevice& into, const NBNode& n, const bool checkLaneFoes);
150 
151 
156  static bool writeInternalNodes(OutputDevice& into, const NBNode& n);
157 
158 
163  static bool writeInternalConnections(OutputDevice& into, const NBNode& n);
164 
165 
170  static void writeDistrict(OutputDevice& into, const NBDistrict& d);
171 
172 private:
179  static void writeInternalConnection(OutputDevice& into,
180  const std::string& from, const std::string& to,
181  int fromLane, int toLane, const std::string& via);
182 
184  static std::string writeSUMOTime(SUMOTime time);
185 
186 
188  static std::string prohibitionConnection(const NBConnection& c);
189 
195  static void writeRoundabout(OutputDevice& into, const std::vector<std::string>& r,
196  const NBEdgeCont& ec);
197 
199  static std::string getOppositeInternalID(const NBEdgeCont& ec, const NBEdge* from, const NBEdge::Connection& con);
200 
201 };
202 
203 
204 #endif
205 
206 /****************************************************************************/
207 
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:150
long long int SUMOTime
Definition: SUMOTime.h:43
static void writeDistrict(OutputDevice &into, const NBDistrict &d)
Writes a district.
A container for traffic light definitions and built programs.
static bool writeInternalEdges(OutputDevice &into, const NBEdgeCont &ec, const NBNode &n, bool origNames)
Writes internal edges (<edge ... with id[0]==&#39;:&#39;) of the given node.
int SVCPermissions
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 void writeInternalConnection(OutputDevice &into, const std::string &from, const std::string &to, int fromLane, int toLane, const std::string &via)
Writes a single internal connection.
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
A class representing a single district.
Definition: NBDistrict.h:72
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.
static void writeLane(OutputDevice &into, const std::string &lID, SUMOReal speed, SVCPermissions permissions, SVCPermissions preferred, SUMOReal endOffset, SUMOReal width, PositionVector shape, const std::string &origID, SUMOReal length, int index, bool origNames, const std::string &oppositeID, const NBNode *node=0)
Writes a lane (<lane ...) of an edge.
A list of positions.
static void writeEdge(OutputDevice &into, const NBEdge &e, bool noNames, bool origNames)
Writes an edge (<edge ...)
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
Exporter writing networks using the SUMO format.
Definition: NWWriter_SUMO.h:63
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:112
static bool writeInternalNodes(OutputDevice &into, const NBNode &n)
Writes internal junctions (<junction with id[0]==&#39;:&#39; ...) of the given node.
A storage for options typed value containers)
Definition: OptionsCont.h:99
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:71
#define SUMOReal
Definition: config.h:213
static void writeJunction(OutputDevice &into, const NBNode &n, const bool checkLaneFoes)
Writes a junction (<junction ...)
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)