Eclipse SUMO - Simulation of Urban MObility
NWWriter_SUMO Class Reference

Exporter writing networks using the SUMO format. More...

#include <NWWriter_SUMO.h>

Public Types

enum  ConnectionStyle { SUMONET , PLAIN , TLL }
 

Static Public Member Functions

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) More...
 
static void writeDistrict (OutputDevice &into, const NBDistrict &d)
 Writes a district. More...
 
static void writeNetwork (const OptionsCont &oc, NBNetBuilder &nb)
 Writes the network into a SUMO-file. More...
 
static void writeProhibitions (OutputDevice &into, const NBConnectionProhibits &prohibitions)
 writes the given prohibitions More...
 
static void writeRoundabouts (OutputDevice &into, const std::set< EdgeSet > &roundabouts, const NBEdgeCont &ec)
 Writes roundabouts. More...
 
static void writeStopOffsets (OutputDevice &into, const std::map< SVCPermissions, double > &stopOffsets)
 Write a stopOffset element into output device. More...
 
static void writeTrafficLight (OutputDevice &into, const NBTrafficLightLogic *logic)
 writes a single traffic light logic to the given device More...
 
static void writeTrafficLights (OutputDevice &into, const NBTrafficLightLogicCont &tllCont)
 writes the traffic light logics to the given device More...
 

Static Private Member Functions

Methods for writing network parts
static bool writeInternalEdges (OutputDevice &into, const NBEdgeCont &ec, const NBNode &n)
 Writes internal edges (<edge ... with id[0]==':') of the given node. More...
 
static void writeEdge (OutputDevice &into, const NBEdge &e, bool noNames)
 Writes an edge (<edge ...) More...
 
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. More...
 
static void writeJunction (OutputDevice &into, const NBNode &n)
 Writes a junction (<junction ...) More...
 
static bool writeInternalNodes (OutputDevice &into, const NBNode &n)
 Writes internal junctions (<junction with id[0]==':' ...) of the given node. More...
 
static bool writeInternalConnections (OutputDevice &into, const NBNode &n)
 Writes inner connections within the node. More...
 
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)
 Writes a single internal connection. More...
 
static std::string writeSUMOTime (SUMOTime time)
 writes a SUMOTime as int if possible, otherwise as a float More...
 
static std::string prohibitionConnection (const NBConnection &c)
 the attribute value for a prohibition More...
 
static void writeRoundabout (OutputDevice &into, const std::vector< std::string > &r, const NBEdgeCont &ec)
 Writes a roundabout. More...
 
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 More...
 

Detailed Description

Exporter writing networks using the SUMO format.

Definition at line 55 of file NWWriter_SUMO.h.

Member Enumeration Documentation

◆ ConnectionStyle

Enumerator
SUMONET 
PLAIN 
TLL 

Definition at line 58 of file NWWriter_SUMO.h.

Member Function Documentation

◆ getOppositeInternalID()

std::string NWWriter_SUMO::getOppositeInternalID ( const NBEdgeCont ec,
const NBEdge from,
const NBEdge::Connection con,
double &  oppositeLength 
)
staticprivate

retrieve the id of the opposite direction internal lane if it exists

Definition at line 236 of file NWWriter_SUMO.cpp.

References NBEdge::Connection::fromLane, OptionsCont::getBool(), NBEdge::getConnections(), NBEdge::Connection::getDescription(), NBNode::getDirection(), NBEdge::Connection::getInternalLaneID(), NBEdge::getLaneID(), NBEdge::getLanes(), OptionsCont::getOptions(), NBEdge::getToNode(), NBEdge::Connection::length, NBEdge::Lane::oppositeID, NBEdgeCont::retrieve(), STRAIGHT, NBEdge::Connection::toEdge, and NBEdge::Connection::toLane.

Referenced by writeInternalEdges().

Here is the caller graph for this function:

◆ prohibitionConnection()

std::string NWWriter_SUMO::prohibitionConnection ( const NBConnection c)
staticprivate

the attribute value for a prohibition

Definition at line 928 of file NWWriter_SUMO.cpp.

References NBConnection::getFrom(), NBEdge::getID(), and NBConnection::getTo().

Referenced by writeProhibitions().

Here is the caller graph for this function:

◆ writeConnection()

void NWWriter_SUMO::writeConnection ( OutputDevice into,
const NBEdge from,
const NBEdge::Connection c,
bool  includeInternal,
ConnectionStyle  style = SUMONET,
bool  geoAccuracy = false 
)
static

Writes connections outgoing from the given edge (also used in NWWriter_XML)

Parameters
[in]intoThe device to write the edge into
[in]fromThe edge to write connections for
[in]cThe connection to write
[in]includeInternalWhether information about inner-lanes used to cross the intersection shall be written
[in]plainWhether only plain-xml output should be written (omit some attributes)

Definition at line 677 of file NWWriter_SUMO.cpp.

References OutputDevice::closeTag(), NBEdge::Connection::contPos, NBEdge::Connection::customLength, NBEdge::Connection::customShape, NBEdge::Connection::fromLane, OptionsCont::getBool(), NBNode::getDirection(), OptionsCont::getFloat(), NBEdge::getID(), NBEdge::Connection::getInternalLaneID(), NBEdge::getJunctionPriority(), NBNode::getLinkState(), OptionsCont::getOptions(), NBEdge::getToNode(), gPrecisionGeo, NBEdge::Connection::keepClear, KEEPCLEAR_FALSE, LINKSTATE_MINOR, NBEdge::Connection::mayDefinitelyPass, NODIR, OutputDevice::openTag(), NBEdge::Connection::permissions, PLAIN, OutputDevice::setPrecision(), NBEdge::Connection::speed, SUMO_ATTR_CONTPOS, SUMO_ATTR_DIR, SUMO_ATTR_FROM, SUMO_ATTR_FROM_LANE, SUMO_ATTR_KEEP_CLEAR, SUMO_ATTR_LENGTH, SUMO_ATTR_PASS, SUMO_ATTR_SHAPE, SUMO_ATTR_SPEED, SUMO_ATTR_STATE, SUMO_ATTR_TLID, SUMO_ATTR_TLLINKINDEX, SUMO_ATTR_TLLINKINDEX2, SUMO_ATTR_TO, SUMO_ATTR_TO_LANE, SUMO_ATTR_UNCONTROLLED, SUMO_ATTR_VIA, SUMO_ATTR_VISIBILITY_DISTANCE, SUMO_TAG_CONNECTION, SUMONET, SVC_UNSPECIFIED, NBEdge::Connection::tlID, TLL, NBEdge::Connection::tlLinkIndex, NBEdge::Connection::tlLinkIndex2, NBEdge::Connection::toEdge, NBEdge::Connection::toLane, toString(), NBEdge::Connection::uncontrolled, NBEdge::UNSPECIFIED_CONTPOS, NBEdge::UNSPECIFIED_LOADED_LENGTH, NBEdge::UNSPECIFIED_SPEED, NBEdge::UNSPECIFIED_VISIBILITY_DISTANCE, NBEdge::Connection::visibility, OutputDevice::writeAttr(), Parameterised::writeParams(), and writePermissions().

Referenced by NWWriter_XML::writeEdgesAndConnections(), writeNetwork(), and NWWriter_XML::writeTrafficLights().

Here is the caller graph for this function:

◆ writeDistrict()

void NWWriter_SUMO::writeDistrict ( OutputDevice into,
const NBDistrict d 
)
static

Writes a district.

Parameters
[in]intoThe device to write the edge into
[in]dThe district

Definition at line 871 of file NWWriter_SUMO.cpp.

References OutputDevice::closeTag(), Named::getID(), NBDistrict::getShape(), NBDistrict::getSinkEdges(), NBDistrict::getSinkWeights(), NBDistrict::getSourceEdges(), NBDistrict::getSourceWeights(), VectorHelper< T >::normaliseSum(), OutputDevice::openTag(), SUMO_ATTR_ID, SUMO_ATTR_SHAPE, SUMO_ATTR_WEIGHT, SUMO_TAG_TAZ, SUMO_TAG_TAZSINK, SUMO_TAG_TAZSOURCE, and OutputDevice::writeAttr().

Referenced by NWWriter_XML::writeDistricts(), and writeNetwork().

Here is the caller graph for this function:

◆ writeEdge()

void NWWriter_SUMO::writeEdge ( OutputDevice into,
const NBEdge e,
bool  noNames 
)
staticprivate

Writes an edge (<edge ...)

Parameters
[in]intoThe device to write the edge into
[in]eThe edge to write
[in]noNamesWhether names shall be ignored
See also
writeLane()

Definition at line 417 of file NWWriter_SUMO.cpp.

References NBEdge::Lane::accelRamp, OutputDevice::closeTag(), CONNECTOR, NBEdge::Lane::customShape, NBEdge::Lane::endOffset, StringUtils::escapeXML(), NBEdge::getDistance(), NBEdge::getEndOffset(), NBEdge::getFinalLength(), NBEdge::getFromNode(), NBEdge::getGeometry(), NBEdge::getID(), Named::getID(), NBEdge::getLaneID(), NBEdge::getLanes(), NBEdge::getLaneSpreadFunction(), NBEdge::getLoadedLength(), NBEdge::getPriority(), NBEdge::getStopOffsets(), NBEdge::getStreetName(), NBEdge::getToNode(), NBEdge::getTurnDestination(), NBEdge::getTypeID(), NBEdge::hasDefaultGeometry(), NBEdge::hasLoadedLength(), NBEdge::isBidiRail(), NBEdge::isMacroscopicConnector(), OutputDevice::openTag(), NBEdge::Lane::oppositeID, NBEdge::Lane::permissions, NBEdge::Lane::preferred, RIGHT, NBEdge::Lane::shape, NBEdge::Lane::speed, NBEdge::Lane::stopOffsets, SUMO_ATTR_BIDI, SUMO_ATTR_DISTANCE, SUMO_ATTR_FROM, SUMO_ATTR_FUNCTION, SUMO_ATTR_ID, SUMO_ATTR_LENGTH, SUMO_ATTR_NAME, SUMO_ATTR_PRIORITY, SUMO_ATTR_SHAPE, SUMO_ATTR_SPREADTYPE, SUMO_ATTR_TO, SUMO_ATTR_TYPE, SUMO_TAG_EDGE, NBEdge::Lane::type, NBEdge::Lane::width, OutputDevice::writeAttr(), writeLane(), Parameterised::writeParams(), and writeStopOffsets().

Referenced by writeNetwork().

Here is the caller graph for this function:

◆ writeInternalConnection()

void NWWriter_SUMO::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 
)
staticprivate

Writes a single internal connection.

Parameters
[in]fromThe id of the from-edge
[in]toThe id of the to-edge
[in]toLaneThe indexd of the to-lane
[in]viaThe (optional) via edge

Definition at line 792 of file NWWriter_SUMO.cpp.

References OutputDevice::closeTag(), NBConnection::InvalidTlIndex, OutputDevice::openTag(), SUMO_ATTR_DIR, SUMO_ATTR_FROM, SUMO_ATTR_FROM_LANE, SUMO_ATTR_STATE, SUMO_ATTR_TLID, SUMO_ATTR_TLLINKINDEX, SUMO_ATTR_TO, SUMO_ATTR_TO_LANE, SUMO_ATTR_VIA, SUMO_TAG_CONNECTION, and OutputDevice::writeAttr().

Referenced by writeInternalConnections(), and writeNetwork().

Here is the caller graph for this function:

◆ writeInternalConnections()

bool NWWriter_SUMO::writeInternalConnections ( OutputDevice into,
const NBNode n 
)
staticprivate

Writes inner connections within the node.

Parameters
[in]intoThe device to write the edge into
[in]nThe node to write inner links for

Definition at line 759 of file NWWriter_SUMO.cpp.

References OptionsCont::getBool(), NBEdge::getConnections(), NBNode::getDirection(), NBEdge::getID(), NBNode::getIncomingEdges(), OptionsCont::getOptions(), NBEdge::Connection::haveVia, NBEdge::Connection::id, NBEdge::Connection::internalLaneIndex, NBConnection::InvalidTlIndex, NBEdge::Connection::tlID, NBEdge::Connection::tlLinkIndex2, NBEdge::Connection::toEdge, NBEdge::Connection::toLane, NBEdge::Connection::viaID, and writeInternalConnection().

Referenced by writeNetwork().

Here is the caller graph for this function:

◆ writeInternalEdges()

bool NWWriter_SUMO::writeInternalEdges ( OutputDevice into,
const NBEdgeCont ec,
const NBNode n 
)
staticprivate

◆ writeInternalNodes()

bool NWWriter_SUMO::writeInternalNodes ( OutputDevice into,
const NBNode n 
)
staticprivate

Writes internal junctions (<junction with id[0]==':' ...) of the given node.

Parameters
[in]intoThe device to write the edge into
[in]nThe junction/node to write internal nodes for

Definition at line 624 of file NWWriter_SUMO.cpp.

References OutputDevice::closeTag(), NBNode::getCrossings(), NBNode::getIncomingEdges(), INTERNAL, joinToString(), OutputDevice::openTag(), SUMO_ATTR_ID, SUMO_ATTR_INCLANES, SUMO_ATTR_INTLANES, SUMO_ATTR_TYPE, SUMO_TAG_JUNCTION, OutputDevice::writeAttr(), and NWFrame::writePositionLong().

Referenced by writeNetwork().

Here is the caller graph for this function:

◆ writeJunction()

◆ writeLane()

void NWWriter_SUMO::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 
)
staticprivate

Writes a lane (<lane ...) of an edge.

Parameters
[in]intoThe device to write the edge into
[in]lIDThe ID of the lane
[in]origIDThe original ID of the edge in the input
[in]lengthLane's length
[in]indexThe index of the lane within the edge
[in]oppositeIDThe ID of the opposite lane for overtaking
[in]accelRampwhether this lane is an acceleration lane
[in]customShapewhether this lane has a custom shape

Definition at line 476 of file NWWriter_SUMO.cpp.

References OutputDevice::closeTag(), OptionsCont::getOptions(), PositionVector::getSubpart(), PositionVector::length(), OutputDevice::openTag(), SUMO_ATTR_ACCELERATION, SUMO_ATTR_CUSTOMSHAPE, SUMO_ATTR_ENDOFFSET, SUMO_ATTR_ID, SUMO_ATTR_INDEX, SUMO_ATTR_LANE, SUMO_ATTR_LENGTH, SUMO_ATTR_SHAPE, SUMO_ATTR_SPEED, SUMO_ATTR_TYPE, SUMO_ATTR_WIDTH, SUMO_TAG_LANE, SUMO_TAG_NEIGH, SVC_UNSPECIFIED, toString(), NBEdge::UNSPECIFIED_OFFSET, NBEdge::UNSPECIFIED_WIDTH, WRITE_ERROR, WRITE_WARNINGF, OutputDevice::writeAttr(), Parameterised::writeParams(), writePermissions(), writePreferences(), and writeStopOffsets().

Referenced by writeEdge(), and writeInternalEdges().

Here is the caller graph for this function:

◆ writeNetwork()

void NWWriter_SUMO::writeNetwork ( const OptionsCont oc,
NBNetBuilder nb 
)
static

Writes the network into a SUMO-file.

Parameters
[in]ocThe options to use
[in]nbThe network builder to fill

Definition at line 55 of file NWWriter_SUMO.cpp.

References NBDistrictCont::begin(), NBEdgeCont::begin(), NBNodeCont::begin(), OutputDevice::close(), OutputDevice::closeTag(), NBDistrictCont::end(), NBEdgeCont::end(), NBNodeCont::end(), OptionsCont::exists(), OptionsCont::getBool(), NBEdge::getConnections(), NBNode::getCrossing(), NBNode::getCrossings(), OutputDevice::getDevice(), NBNetBuilder::getDistrictCont(), NBNetBuilder::getEdgeCont(), OptionsCont::getFloat(), OptionsCont::getInt(), NBNetBuilder::getNodeCont(), OptionsCont::getOptions(), NBEdgeCont::getRoundabouts(), OptionsCont::getString(), NBNetBuilder::getTLLogicCont(), NBNetBuilder::getTypeCont(), NBNode::getWalkingAreas(), NBHelpers::interpretLaneID(), OptionsCont::isDefault(), OptionsCont::isSet(), OutputDevice::lf(), LINKSTATE_MAJOR, LINKSTATE_MINOR, NETWORK_VERSION, OutputDevice::openTag(), NBNode::Crossing::priority, OptionsCont::resetWritable(), OptionsCont::set(), NBDistrictCont::size(), STRAIGHT, SUMO_ATTR_AVOID_OVERLAP, SUMO_ATTR_CHECKLANEFOES_ALL, SUMO_ATTR_CHECKLANEFOES_ROUNDABOUT, SUMO_ATTR_CORNERDETAIL, SUMO_ATTR_DIR, SUMO_ATTR_FROM, SUMO_ATTR_FROM_LANE, SUMO_ATTR_LEFTHAND, SUMO_ATTR_LIMIT_TURN_SPEED, SUMO_ATTR_LINKDETAIL, SUMO_ATTR_RECTANGULAR_LANE_CUT, SUMO_ATTR_SPREADTYPE, SUMO_ATTR_STATE, SUMO_ATTR_TLID, SUMO_ATTR_TLLINKINDEX, SUMO_ATTR_TLS_IGNORE_INTERNAL_JUNCTION_JAM, SUMO_ATTR_TO, SUMO_ATTR_TO_LANE, SUMO_ATTR_VERSION, SUMO_ATTR_WALKINGAREAS, SUMO_TAG_CONNECTION, NBNode::Crossing::tlID, NBNode::Crossing::tlLinkIndex, toString(), WRITE_WARNING, OutputDevice::writeAttr(), writeConnection(), writeDistrict(), writeEdge(), NBTypeCont::writeEdgeTypes(), writeInternalConnection(), writeInternalConnections(), writeInternalEdges(), writeInternalNodes(), writeJunction(), GeoConvHelper::writeLocation(), writeProhibitions(), writeRoundabouts(), writeTrafficLights(), and OutputDevice::writeXMLHeader().

Referenced by NWFrame::writeNetwork().

Here is the caller graph for this function:

◆ writeProhibitions()

void NWWriter_SUMO::writeProhibitions ( OutputDevice into,
const NBConnectionProhibits prohibitions 
)
static

writes the given prohibitions

Definition at line 912 of file NWWriter_SUMO.cpp.

References OutputDevice::closeTag(), OutputDevice::openTag(), prohibitionConnection(), SUMO_ATTR_PROHIBITED, SUMO_ATTR_PROHIBITOR, SUMO_TAG_PROHIBITION, and OutputDevice::writeAttr().

Referenced by NWWriter_XML::writeEdgesAndConnections(), and writeNetwork().

Here is the caller graph for this function:

◆ writeRoundabout()

void NWWriter_SUMO::writeRoundabout ( OutputDevice into,
const std::vector< std::string > &  r,
const NBEdgeCont ec 
)
staticprivate

Writes a roundabout.

Parameters
[in]intoThe device to write the edge into
[in]rThe roundabout to write
[in]ecThe edge control to retrieve named edges from

Definition at line 842 of file NWWriter_SUMO.cpp.

References OutputDevice::closeTag(), NBEdge::getID(), Named::getID(), NBEdge::getToNode(), joinToString(), OutputDevice::openTag(), NBEdgeCont::retrieve(), SUMO_ATTR_EDGES, SUMO_ATTR_NODES, SUMO_TAG_ROUNDABOUT, WRITE_WARNING, and OutputDevice::writeAttr().

Referenced by writeRoundabouts().

Here is the caller graph for this function:

◆ writeRoundabouts()

void NWWriter_SUMO::writeRoundabouts ( OutputDevice into,
const std::set< EdgeSet > &  roundabouts,
const NBEdgeCont ec 
)
static

Writes roundabouts.

Parameters
[in]intoThe device to write the edge into
[in]roundaboutesThe roundabouts to write
[in]ecThe edge control to retrieve named edges from

Definition at line 816 of file NWWriter_SUMO.cpp.

References OutputDevice::lf(), and writeRoundabout().

Referenced by NWWriter_XML::writeEdgesAndConnections(), and writeNetwork().

Here is the caller graph for this function:

◆ writeStopOffsets()

void NWWriter_SUMO::writeStopOffsets ( OutputDevice into,
const std::map< SVCPermissions, double > &  stopOffsets 
)
static

Write a stopOffset element into output device.

Definition at line 984 of file NWWriter_SUMO.cpp.

References OutputDevice::closeTag(), getVehicleClassNames(), OutputDevice::openTag(), SUMO_ATTR_EXCEPTIONS, SUMO_ATTR_VALUE, SUMO_ATTR_VCLASSES, SUMO_TAG_STOPOFFSET, and OutputDevice::writeAttr().

Referenced by writeEdge(), NWWriter_XML::writeEdgesAndConnections(), and writeLane().

Here is the caller graph for this function:

◆ writeSUMOTime()

std::string NWWriter_SUMO::writeSUMOTime ( SUMOTime  time)
staticprivate

writes a SUMOTime as int if possible, otherwise as a float

Definition at line 901 of file NWWriter_SUMO.cpp.

References STEPS2TIME, and toString().

Referenced by writeTrafficLight().

Here is the caller graph for this function:

◆ writeTrafficLight()

◆ writeTrafficLights()

void NWWriter_SUMO::writeTrafficLights ( OutputDevice into,
const NBTrafficLightLogicCont tllCont 
)
static

writes the traffic light logics to the given device

Definition at line 934 of file NWWriter_SUMO.cpp.

References NBTrafficLightLogicCont::getComputed(), OutputDevice::lf(), and writeTrafficLight().

Referenced by GNENet::saveTLSPrograms(), writeNetwork(), and NWWriter_XML::writeTrafficLights().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: