Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NWWriter_SUMO.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/****************************************************************************/
21// Exporter writing networks using the SUMO format
22/****************************************************************************/
23#pragma once
24#include <config.h>
25
26#include <string>
27#include <map>
28#include <netbuild/NBEdge.h>
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class OutputDevice;
38class OptionsCont;
39class NBNetBuilder;
42class NBNode;
43class NBDistrict;
44class NBEdgeControl;
45
46
47// ===========================================================================
48// class definitions
49// ===========================================================================
56public:
57
59 SUMONET, // all connection information
60 PLAIN, // only edges and link indices
61 TLL // like plain but include tl information
62 };
63
69 static void writeNetwork(const OptionsCont& oc, NBNetBuilder& nb);
70
71
79 static void writeConnection(OutputDevice& into, const NBEdge& from, const NBEdge::Connection& c,
80 bool includeInternal, ConnectionStyle style = SUMONET, bool geoAccuracy = false);
81
83 static void writeProhibitions(OutputDevice& into, const NBConnectionProhibits& prohibitions);
84
86 static void writeTrafficLights(OutputDevice& into, const NBTrafficLightLogicCont& tllCont);
87
89 static void writeTrafficLight(OutputDevice& into, const NBTrafficLightLogic* logic);
90
96 static void writeRoundabouts(OutputDevice& into, const std::set<EdgeSet>& roundabouts,
97 const NBEdgeCont& ec);
98
101 static void writeStopOffsets(OutputDevice& into, const StopOffset& stopOffset);
102
107 static void writeDistrict(OutputDevice& into, const NBDistrict& d);
108
109
110private:
113
119 static bool writeInternalEdges(OutputDevice& into, const NBEdgeCont& ec, const NBNode& n);
120
121
123 static std::string getInternalBidi(const NBEdge* e, const NBEdge::Connection& k, double& length);
124
125
132 static void writeEdge(OutputDevice& into, const NBEdge& e, bool noNames);
133
134
145 static void writeLane(OutputDevice& into, const std::string& lID,
146 double speed, double friction,
147 SVCPermissions permissions, SVCPermissions preferred,
148 SVCPermissions changeLeft, SVCPermissions changeRight,
149 double startOffset, double endOffset,
150 const StopOffset& stopOffset, double width, PositionVector shape,
151 const Parameterised* params, double length, int index,
152 const std::string& oppositeID, const std::string& type,
153 bool accelRamp = false,
154 bool customShape = false,
155 const PositionVector& outlineShape = PositionVector());
156
157
162 static void writeJunction(OutputDevice& into, const NBNode& n);
163
164
169 static bool writeInternalNodes(OutputDevice& into, const NBNode& n);
170
171
176 static bool writeInternalConnections(OutputDevice& into, const NBNode& n);
177
178
185 static void writeInternalConnection(OutputDevice& into,
186 const std::string& from, const std::string& to,
187 int fromLane, int toLane, const std::string& via,
189 const std::string& tlID = "",
190 int linkIndex = NBConnection::InvalidTlIndex,
191 bool minor = false,
192 double visibility = NBEdge::UNSPECIFIED_VISIBILITY_DISTANCE);
193
195 static std::string writeSUMOTime(SUMOTime time);
196
198 static std::string prohibitionConnection(const NBConnection& c);
199
205 static void writeRoundabout(OutputDevice& into, const std::vector<std::string>& r,
206 const NBEdgeCont& ec);
207
209 static std::string getOppositeInternalID(const NBEdgeCont& ec, const NBEdge* from, const NBEdge::Connection& con, double& oppositeLength);
210
211};
long long int SUMOTime
Definition GUI.h:36
std::map< NBConnection, NBConnectionVector > NBConnectionProhibits
Definition of a container for connection block dependencies Includes a list of all connections which ...
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
@ STRAIGHT
The link is a straight direction.
static const int InvalidTlIndex
A class representing a single district.
Definition NBDistrict.h:62
Storage for edges, including some functionality operating on multiple edges.
Definition NBEdgeCont.h:59
The representation of a single edge during network building.
Definition NBEdge.h:92
static const double UNSPECIFIED_VISIBILITY_DISTANCE
unspecified foe visibility for connections
Definition NBEdge.h:361
Instance responsible for building networks.
Represents a single node (junction) during network building.
Definition NBNode.h:66
A container for traffic light definitions and built programs.
A SUMO-compliant built logic for a traffic light.
Exporter writing networks using the SUMO format.
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)
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into a SUMO-file.
static bool writeInternalNodes(OutputDevice &into, const NBNode &n)
Writes internal junctions (<junction with id[0]==':' ...) of the given node.
static void writeProhibitions(OutputDevice &into, const NBConnectionProhibits &prohibitions)
writes the given prohibitions
static void writeEdge(OutputDevice &into, const NBEdge &e, bool noNames)
Writes an edge (<edge ...)
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
static std::string writeSUMOTime(SUMOTime time)
writes a SUMOTime as int if possible, otherwise as a float
static void writeJunction(OutputDevice &into, const NBNode &n)
Writes a junction (<junction ...)
static bool writeInternalEdges(OutputDevice &into, const NBEdgeCont &ec, const NBNode &n)
Writes internal edges (<edge ... with id[0]==':') of the given node.
static bool writeInternalConnections(OutputDevice &into, const NBNode &n)
Writes inner connections within the node.
static void writeLane(OutputDevice &into, const std::string &lID, double speed, double friction, SVCPermissions permissions, SVCPermissions preferred, SVCPermissions changeLeft, SVCPermissions changeRight, double startOffset, double endOffset, const StopOffset &stopOffset, 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, const PositionVector &outlineShape=PositionVector())
Writes a lane (<lane ...) of an edge.
static void writeDistrict(OutputDevice &into, const NBDistrict &d)
Writes a district.
static void writeRoundabouts(OutputDevice &into, const std::set< EdgeSet > &roundabouts, const NBEdgeCont &ec)
Writes roundabouts.
static std::string getInternalBidi(const NBEdge *e, const NBEdge::Connection &k, double &length)
retrieve bidi edge id for internal corresponding to the given connection
static void writeRoundabout(OutputDevice &into, const std::vector< std::string > &r, const NBEdgeCont &ec)
Writes a roundabout.
static void writeStopOffsets(OutputDevice &into, const StopOffset &stopOffset)
Write a stopOffset element into output device.
static void writeInternalConnection(OutputDevice &into, const std::string &from, const std::string &to, int fromLane, int toLane, const std::string &via, LinkDirection dir=LinkDirection::STRAIGHT, const std::string &tlID="", int linkIndex=NBConnection::InvalidTlIndex, bool minor=false, double visibility=NBEdge::UNSPECIFIED_VISIBILITY_DISTANCE)
Writes a single internal connection.
static void writeTrafficLight(OutputDevice &into, const NBTrafficLightLogic *logic)
writes a single traffic light logic to the given device
static std::string prohibitionConnection(const NBConnection &c)
the attribute value for a prohibition
static void writeTrafficLights(OutputDevice &into, const NBTrafficLightLogicCont &tllCont)
writes the traffic light logics to the given device
A storage for options typed value containers)
Definition OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
An upper class for objects with additional parameters.
A list of positions.
stop offset
A structure which describes a connection between edges or lanes.
Definition NBEdge.h:201