Eclipse 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-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 /****************************************************************************/
17 // Exporter writing networks using the SUMO format
18 /****************************************************************************/
19 #ifndef NWWriter_SUMO_h
20 #define NWWriter_SUMO_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <map>
30 #include <netbuild/NBEdge.h>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class OutputDevice;
40 class OptionsCont;
41 class NBNetBuilder;
43 class NBNode;
44 class NBDistrict;
45 class NBEdgeControl;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
57 public:
58 
60  SUMONET, // all connection information
61  PLAIN, // only edges and link indices
62  TLL // like plain but include tl information
63  };
64 
70  static void writeNetwork(const OptionsCont& oc, NBNetBuilder& nb);
71 
72 
80  static void writeConnection(OutputDevice& into, const NBEdge& from, const NBEdge::Connection& c,
81  bool includeInternal, ConnectionStyle style = SUMONET, bool geoAccuracy = false);
82 
84  static void writeProhibitions(OutputDevice& into, const NBConnectionProhibits& prohibitions);
85 
87  static void writeTrafficLights(OutputDevice& into, const NBTrafficLightLogicCont& tllCont);
88 
94  static void writeRoundabouts(OutputDevice& into, const std::set<EdgeSet>& roundabouts,
95  const NBEdgeCont& ec);
96 
97 
100  static void writeStopOffsets(OutputDevice& into, const std::map<SVCPermissions, double>& stopOffsets);
101 
106  static void writeDistrict(OutputDevice& into, const NBDistrict& d);
107 
108 
109 private:
112 
118  static bool writeInternalEdges(OutputDevice& into, const NBEdgeCont& ec, const NBNode& n);
119 
120 
127  static void writeEdge(OutputDevice& into, const NBEdge& e, bool noNames);
128 
129 
140  static void writeLane(OutputDevice& into, const std::string& lID,
141  double speed, SVCPermissions permissions, SVCPermissions preferred,
142  double startOffset, double endOffset,
143  std::map<SVCPermissions, double> stopOffsets, double width, PositionVector shape,
144  const Parameterised* params, double length, int index,
145  const std::string& oppositeID, const std::string& type,
146  bool accelRamp = false,
147  bool customShape = false);
148 
149 
154  static void writeJunction(OutputDevice& into, const NBNode& n);
155 
156 
161  static bool writeInternalNodes(OutputDevice& into, const NBNode& n);
162 
163 
168  static bool writeInternalConnections(OutputDevice& into, const NBNode& n);
169 
170 
177  static void writeInternalConnection(OutputDevice& into,
178  const std::string& from, const std::string& to,
179  int fromLane, int toLane, const std::string& via,
181  const std::string& tlID = "",
182  int linkIndex = NBConnection::InvalidTlIndex);
183 
185  static std::string writeSUMOTime(SUMOTime time);
186 
187 
189  static std::string prohibitionConnection(const NBConnection& c);
190 
196  static void writeRoundabout(OutputDevice& into, const std::vector<std::string>& r,
197  const NBEdgeCont& ec);
198 
200  static std::string getOppositeInternalID(const NBEdgeCont& ec, const NBEdge* from, const NBEdge::Connection& con, double& oppositeLength);
201 
202 };
203 
204 
205 #endif
206 
207 /****************************************************************************/
208 
NWWriter_SUMO::writeEdge
static void writeEdge(OutputDevice &into, const NBEdge &e, bool noNames)
Writes an edge (<edge ...)
Definition: NWWriter_SUMO.cpp:403
NBConnectionDefs.h
NWWriter_SUMO::writeTrafficLights
static void writeTrafficLights(OutputDevice &into, const NBTrafficLightLogicCont &tllCont)
writes the traffic light logics to the given device
Definition: NWWriter_SUMO.cpp:910
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:42
NBEdgeCont
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:60
NBNetBuilder
Instance responsible for building networks.
Definition: NBNetBuilder.h:109
NBTrafficLightLogicCont
A container for traffic light definitions and built programs.
Definition: NBTrafficLightLogicCont.h:57
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
NWWriter_SUMO::SUMONET
Definition: NWWriter_SUMO.h:60
NWWriter_SUMO::prohibitionConnection
static std::string prohibitionConnection(const NBConnection &c)
the attribute value for a prohibition
Definition: NWWriter_SUMO.cpp:904
NWWriter_SUMO::writeJunction
static void writeJunction(OutputDevice &into, const NBNode &n)
Writes a junction (<junction ...)
Definition: NWWriter_SUMO.cpp:534
SUMOSAXHandler.h
NWWriter_SUMO::writeInternalEdges
static bool writeInternalEdges(OutputDevice &into, const NBEdgeCont &ec, const NBNode &n)
Writes internal edges (<edge ... with id[0]==':') of the given node.
Definition: NWWriter_SUMO.cpp:277
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
NBConnection::InvalidTlIndex
const static int InvalidTlIndex
Definition: NBConnection.h:125
NWWriter_SUMO::writeLane
static void writeLane(OutputDevice &into, const std::string &lID, double speed, SVCPermissions permissions, SVCPermissions preferred, double startOffset, double endOffset, std::map< SVCPermissions, double > stopOffsets, double width, PositionVector shape, const Parameterised *params, double length, int index, const std::string &oppositeID, const std::string &type, bool accelRamp=false, bool customShape=false)
Writes a lane (<lane ...) of an edge.
Definition: NWWriter_SUMO.cpp:462
NWWriter_SUMO::TLL
Definition: NWWriter_SUMO.h:62
LinkDirection
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
Definition: SUMOXMLDefinitions.h:1176
PositionVector
A list of positions.
Definition: PositionVector.h:45
NWWriter_SUMO::writeNetwork
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into a SUMO-file.
Definition: NWWriter_SUMO.cpp:56
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:91
NWWriter_SUMO::writeProhibitions
static void writeProhibitions(OutputDevice &into, const NBConnectionProhibits &prohibitions)
writes the given prohibitions
Definition: NWWriter_SUMO.cpp:888
NWWriter_SUMO::getOppositeInternalID
static std::string getOppositeInternalID(const NBEdgeCont &ec, const NBEdge *from, const NBEdge::Connection &con, double &oppositeLength)
retrieve the id of the opposite direction internal lane if it exists
Definition: NWWriter_SUMO.cpp:224
LINKDIR_STRAIGHT
The link is a straight direction.
Definition: SUMOXMLDefinitions.h:1178
NWWriter_SUMO::writeSUMOTime
static std::string writeSUMOTime(SUMOTime time)
writes a SUMOTime as int if possible, otherwise as a float
Definition: NWWriter_SUMO.cpp:877
NWWriter_SUMO::writeInternalNodes
static bool writeInternalNodes(OutputDevice &into, const NBNode &n)
Writes internal junctions (<junction with id[0]==':' ...) of the given node.
Definition: NWWriter_SUMO.cpp:615
NWWriter_SUMO::writeRoundabout
static void writeRoundabout(OutputDevice &into, const std::vector< std::string > &r, const NBEdgeCont &ec)
Writes a roundabout.
Definition: NWWriter_SUMO.cpp:818
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
NWWriter_SUMO::writeConnection
static void writeConnection(OutputDevice &into, const NBEdge &from, const NBEdge::Connection &c, bool includeInternal, ConnectionStyle style=SUMONET, bool geoAccuracy=false)
Writes connections outgoing from the given edge (also used in NWWriter_XML)
Definition: NWWriter_SUMO.cpp:668
UtilExceptions.h
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
NWWriter_SUMO::ConnectionStyle
ConnectionStyle
Definition: NWWriter_SUMO.h:59
NBConnection
Definition: NBConnection.h:43
NWWriter_SUMO::writeInternalConnections
static bool writeInternalConnections(OutputDevice &into, const NBNode &n)
Writes inner connections within the node.
Definition: NWWriter_SUMO.cpp:735
NBConnectionProhibits
std::map< NBConnection, NBConnectionVector > NBConnectionProhibits
Definition of a container for connection block dependencies Includes a list of all connections which ...
Definition: NBConnectionDefs.h:39
NWWriter_SUMO::writeDistrict
static void writeDistrict(OutputDevice &into, const NBDistrict &d)
Writes a district.
Definition: NWWriter_SUMO.cpp:847
NWWriter_SUMO
Exporter writing networks using the SUMO format.
Definition: NWWriter_SUMO.h:56
NWWriter_SUMO::writeStopOffsets
static void writeStopOffsets(OutputDevice &into, const std::map< SVCPermissions, double > &stopOffsets)
Write a stopOffset element into output device.
Definition: NWWriter_SUMO.cpp:955
NWWriter_SUMO::PLAIN
Definition: NWWriter_SUMO.h:61
config.h
NWWriter_SUMO::writeInternalConnection
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, const std::string &tlID="", int linkIndex=NBConnection::InvalidTlIndex)
Writes a single internal connection.
Definition: NWWriter_SUMO.cpp:768
NWWriter_SUMO::writeRoundabouts
static void writeRoundabouts(OutputDevice &into, const std::set< EdgeSet > &roundabouts, const NBEdgeCont &ec)
Writes roundabouts.
Definition: NWWriter_SUMO.cpp:792
NBNode
Represents a single node (junction) during network building.
Definition: NBNode.h:67
NBEdge::Connection
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:189
NBDistrict
A class representing a single district.
Definition: NBDistrict.h:64
NBEdge.h