Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NWWriter_XML.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 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 XML (native input) format
22/****************************************************************************/
23#include <config.h>
24
25#include <algorithm>
33#include <netbuild/NBEdge.h>
34#include <netbuild/NBEdgeCont.h>
35#include <netbuild/NBNode.h>
36#include <netbuild/NBNodeCont.h>
39#include <netbuild/NBPTStop.h>
40#include <netbuild/NBParking.h>
41#include "NWFrame.h"
42#include "NWWriter_SUMO.h"
43#include "NWWriter_DlrNavteq.h"
44#include "NWWriter_XML.h"
45
46
47// ===========================================================================
48// method definitions
49// ===========================================================================
50// ---------------------------------------------------------------------------
51// static methods
52// ---------------------------------------------------------------------------
53void
54NWWriter_XML::writeNetwork(const OptionsCont& oc, const std::string& prefix, NBNetBuilder& nb) {
55 // check whether plain-output files shall be generated
56 if (prefix != "") {
57 const bool haveTypes = nb.getTypeCont().size() > 0;
58 writeNodes(oc, prefix, nb.getNodeCont());
59 if (haveTypes) {
60 writeTypes(prefix, nb.getEdgeCont(), nb.getTypeCont());
61 }
62 writeEdgesAndConnections(oc, prefix, nb.getNodeCont(), nb.getEdgeCont());
64 writeConfig(oc, prefix, haveTypes);
65 }
66 if (oc.isSet("junctions.join-output") && (oc.getString("junctions.join-output").size() > 0)) {
67 writeJoinedJunctions(oc.getString("junctions.join-output"), nb.getNodeCont());
68 }
69 if (oc.isSet("street-sign-output") && (oc.getString("street-sign-output").size() > 0)) {
71 }
72 if (oc.exists("ptstop-output") && oc.isSet("ptstop-output") && (oc.getString("ptstop-output").size() > 0)) {
74 }
75 if (oc.exists("ptline-output") && oc.isSet("ptline-output") && (oc.getString("ptline-output").size() > 0)) {
77 }
78 if (oc.exists("parking-output") && oc.isSet("parking-output") && (oc.getString("parking-output").size() > 0)) {
80 }
81 if (oc.exists("taz-output") && oc.isSet("taz-output") && (oc.getString("taz-output").size() > 0)) {
83 }
84}
85
86
87void
88NWWriter_XML::writeConfig(const OptionsCont& oc, const std::string& prefix, bool haveTypes) {
89 if (!oc.exists("node-files")) {
90 // do not write configuration for netgen
91 return;
92 }
93 const std::string ext = oc.getString("output.format");
94 OptionsCont* tmp = oc.clone();
95 tmp->set("node-files", prefix + ".nod." + ext);
96 tmp->set("edge-files", prefix + ".edg." + ext);
97 tmp->set("connection-files", prefix + ".con." + ext);
98 tmp->set("tllogic-files", prefix + ".tll." + ext);
99 if (haveTypes) {
100 tmp->set("type-files", prefix + ".typ." + ext);
101 }
102 tmp->setDefault("sumo-net-file", "");
103 tmp->setDefault("plain-output-prefix", "");
104
105 const std::string configPath = prefix + ".netccfg";
106 std::ofstream out(configPath.c_str());
107 if (!out.good()) {
108 delete tmp;
109 throw ProcessError(TLF("Could not save configuration to '%'", configPath));
110 } else {
111 tmp->writeConfiguration(out, true, false, false);
112 }
113 delete tmp;
114}
115
116
117void
118NWWriter_XML::writeNodes(const OptionsCont& oc, const std::string& prefix, NBNodeCont& nc) {
119 const std::string ext = oc.getString("output.format");
121 bool useGeo = oc.exists("proj.plain-geo") && oc.getBool("proj.plain-geo");
122 if (useGeo && !gch.usingGeoProjection()) {
123 WRITE_WARNING(TL("Ignoring option \"proj.plain-geo\" because no geo-conversion has been defined"));
124 useGeo = false;
125 }
126 const bool geoAccuracy = useGeo || gch.usingInverseGeoProjection();
127
128 OutputDevice& device = OutputDevice::getDevice(prefix + ".nod." + ext);
129 std::map<SumoXMLAttr, std::string> attrs;
131 device.writeXMLHeader("nodes", "nodes_file.xsd", attrs);
132
133 // write network offsets and projection to allow reconstruction of original coordinates
134 if (!useGeo) {
136 }
137
138 // write nodes
139 TrafficLightType tlsDefaultType = SUMOXMLDefinitions::TrafficLightTypes.get(oc.getString("tls.default-type"));
140 for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
141 NBNode* n = (*i).second;
142 device.openTag(SUMO_TAG_NODE);
143 device.writeAttr(SUMO_ATTR_ID, n->getID());
144 // write position
145 Position pos = n->getPosition();
146 if (useGeo) {
147 gch.cartesian2geo(pos);
148 }
149 if (geoAccuracy) {
151 }
152 NWFrame::writePositionLong(pos, device);
153 if (geoAccuracy) {
154 device.setPrecision();
155 }
156
158 // std::set is already sorted, so the output is stable
159 std::set<std::string> tlsIDs;
160 std::set<std::string> controlledInnerEdges;
161 std::string tlType = "";
163 tlsIDs.insert(tl->getID());
164 std::vector<std::string> cie = tl->getControlledInnerEdges();
165 controlledInnerEdges.insert(cie.begin(), cie.end());
166 if (tl->getType() != tlsDefaultType) {
167 tlType = toString(tl->getType());
168 }
169 }
170 device.writeOptionalAttr(SUMO_ATTR_TLID, tlsIDs, tlsIDs.empty());
171 device.writeOptionalAttr(SUMO_ATTR_TLTYPE, tlType, tlType == "");
172 device.writeOptionalAttr(SUMO_ATTR_CONTROLLED_INNER, controlledInnerEdges, controlledInnerEdges.empty());
173 NWWriter_SUMO::writeShape(device, gch, n->getShape(), SUMO_ATTR_SHAPE, useGeo, geoAccuracy, n->hasCustomShape());
180 XMLHelpers::writeParams(device, *n);
181 device.closeTag();
182 }
183 device.close();
184}
185
186
187void
188NWWriter_XML::writeTypes(const std::string& prefix, NBEdgeCont& ec, NBTypeCont& tc) {
189 const std::string ext = OptionsCont::getOptions().getString("output.format");
190 OutputDevice& device = OutputDevice::getDevice(prefix + ".typ." + ext);
191 std::map<SumoXMLAttr, std::string> attrs;
193 device.writeXMLHeader(toString(SUMO_TAG_TYPES), "types_file.xsd", attrs);
194 std::set<std::string> usedTypes = ec.getUsedTypes();
195 tc.writeEdgeTypes(device, usedTypes);
196 device.close();
197}
198
199
200void
201NWWriter_XML::writeEdgesAndConnections(const OptionsCont& oc, const std::string& prefix, NBNodeCont& nc, NBEdgeCont& ec) {
202 const std::string ext = oc.getString("output.format");
204 bool useGeo = oc.exists("proj.plain-geo") && oc.getBool("proj.plain-geo");
205 const bool geoAccuracy = useGeo || gch.usingInverseGeoProjection();
206 const bool dlrNavteq = oc.exists("dlr-navteq.plain") && oc.getBool("dlr-navteq.plain");
207
208 std::map<SumoXMLAttr, std::string> attrs;
210 OutputDevice& edevice = OutputDevice::getDevice(prefix + ".edg." + ext);
211 edevice.writeXMLHeader("edges", "edges_file.xsd", attrs);
212 OutputDevice& cdevice = OutputDevice::getDevice(prefix + ".con." + ext);
213 cdevice.writeXMLHeader("connections", "connections_file.xsd", attrs);
214 const bool writeNames = oc.getBool("output.street-names");
215 const bool writeLanes = oc.getBool("plain-output.lanes");
216
217 // write network offsets and projection to allow reconstruction of original coordinates at least for geo-referenced networks
218 if (!useGeo && gch.usingGeoProjection()) {
220 }
221 LaneSpreadFunction defaultSpread = SUMOXMLDefinitions::LaneSpreadFunctions.get(oc.getString("default.spreadtype"));
222 for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
223 // write the edge itself to the edges-files
224 NBEdge* e = (*i).second;
225 edevice.openTag(SUMO_TAG_EDGE);
226 edevice.writeAttr(SUMO_ATTR_ID, e->getID());
227 edevice.writeAttr(SUMO_ATTR_FROM, e->getFromNode()->getID());
228 edevice.writeAttr(SUMO_ATTR_TO, e->getToNode()->getID());
229 edevice.writeOptionalAttr(SUMO_ATTR_NAME, StringUtils::escapeXML(e->getStreetName()), !writeNames || e->getStreetName() == "");
231 // write the type if given
232 edevice.writeOptionalAttr(SUMO_ATTR_TYPE, e->getTypeID(), e->getTypeID() == "");
237 // write non-default geometry
238 NWWriter_SUMO::writeShape(edevice, gch, e->getGeometry(), SUMO_ATTR_SHAPE, useGeo, geoAccuracy, !e->hasDefaultGeometry());
239 // write the spread type if not default ("right")
241 // write the length if it was specified
243 // some attributes can be set by edge default or per lane. Write as default if possible (efficiency)
246 // SVC_UNSPECIFIED is here a shortcut for do not write
250 }
252 edevice.writeOptionalAttr(SUMO_ATTR_BIDI, e->getBidiEdge() == nullptr ? "" : e->getBidiEdge()->getID(), e->getBidiEdge() == nullptr);
253 if (dlrNavteq) {
255 }
256 if (e->needsLaneSpecificOutput() || writeLanes) {
257 int idx = 0;
258 for (const NBEdge::Lane& lane : e->getLanes()) {
259 edevice.openTag(SUMO_TAG_LANE);
260 edevice.writeAttr(SUMO_ATTR_INDEX, idx++);
261 XMLHelpers::writePermissions(edevice, e->hasLaneSpecificPermissions() || writeLanes ? lane.permissions : SVC_UNSPECIFIED);
262 XMLHelpers::writePreferences(edevice, lane.preferred);
263 edevice.writeOptionalAttr(SUMO_ATTR_WIDTH, lane.width, lane.width == NBEdge::UNSPECIFIED_WIDTH || !(e->hasLaneSpecificWidth() || writeLanes));
264 edevice.writeOptionalAttr(SUMO_ATTR_ENDOFFSET, lane.endOffset, lane.endOffset == NBEdge::UNSPECIFIED_OFFSET || !(e->hasLaneSpecificEndOffset() || writeLanes));
265 edevice.writeOptionalAttr(SUMO_ATTR_SPEED, lane.speed, !(e->hasLaneSpecificSpeed() || writeLanes));
266 edevice.writeOptionalAttr(SUMO_ATTR_ACCELERATION, lane.accelRamp, !lane.accelRamp);
267 NWWriter_SUMO::writeShape(edevice, gch, lane.customShape.size() > 0 ? lane.customShape : lane.shape, SUMO_ATTR_SHAPE, useGeo, geoAccuracy, lane.customShape.size() > 0 || writeLanes);
268 edevice.writeOptionalAttr(SUMO_ATTR_TYPE, lane.type, lane.type == "");
269 const bool changeLeft = (lane.changeLeft != SVCAll && lane.changeLeft != SVC_UNSPECIFIED && lane.changeLeft != SVC_IGNORING);
270 edevice.writeOptionalAttr(SUMO_ATTR_CHANGE_LEFT, getVehicleClassNames(lane.changeLeft), !changeLeft);
271 const bool changeRight = (lane.changeRight != SVCAll && lane.changeRight != SVC_UNSPECIFIED && lane.changeRight != SVC_IGNORING);
272 edevice.writeOptionalAttr(SUMO_ATTR_CHANGE_RIGHT, getVehicleClassNames(lane.changeRight), !changeRight);
273 if (lane.oppositeID != "") {
274 edevice.openTag(SUMO_TAG_NEIGH);
275 edevice.writeAttr(SUMO_ATTR_LANE, lane.oppositeID);
276 edevice.closeTag();
277 }
278 XMLHelpers::writeParams(edevice, lane);
279 NWWriter_SUMO::writeStopOffsets(edevice, lane.laneStopOffset);
280 edevice.closeTag();
281 }
282 }
283 XMLHelpers::writeParams(edevice, *e);
284 edevice.closeTag();
285 // write this edge's connections to the connections-files
286 const std::vector<NBEdge::Connection> connections = e->getConnections();
287 if (connections.empty()) {
288 // if there are no connections and this appears to be customized, preserve the information
289 const int numOutgoing = (int)e->getToNode()->getOutgoingEdges().size();
290 if (numOutgoing > 0) {
291 const SVCPermissions inPerm = e->getPermissions();
292 SVCPermissions outPerm = 0;
293 for (auto out : e->getToNode()->getOutgoingEdges()) {
294 outPerm |= out->getPermissions();
295 }
296 if ((inPerm & outPerm) != 0 && (inPerm & outPerm) != SVC_PEDESTRIAN) {
298 cdevice.writeAttr(SUMO_ATTR_FROM, e->getID());
299 cdevice.closeTag();
300 cdevice.lf();
301 }
302 }
303 } else {
304 for (NBEdge::Connection c : connections) {
305 NWWriter_SUMO::writeConnection(cdevice, *e, c, false, dlrNavteq ? NWWriter_SUMO::PLAIN_NAVTEQ : NWWriter_SUMO::PLAIN, useGeo, geoAccuracy);
306 }
307 cdevice.lf();
308 }
309 }
310 // write roundabout information to the edges-files
311 if (ec.getRoundabouts().size() > 0) {
312 edevice.lf();
314 }
315
316 // write loaded prohibitions to the connections-file
317 for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
318 NWWriter_SUMO::writeProhibitions(cdevice, i->second->getProhibitions(), ec);
319 }
320 // write pedestrian crossings to the connections-file
321 for (std::map<std::string, NBNode*>::const_iterator it_node = nc.begin(); it_node != nc.end(); ++it_node) {
322 const std::vector<NBNode::Crossing*>& crossings = (*it_node).second->getCrossings();
323 for (auto c : crossings) {
324 cdevice.openTag(SUMO_TAG_CROSSING);
325 cdevice.writeAttr(SUMO_ATTR_NODE, (*it_node).second->getID());
326 cdevice.writeAttr(SUMO_ATTR_EDGES, c->edges);
327 cdevice.writeAttr(SUMO_ATTR_PRIORITY, c->priority);
328 cdevice.writeOptionalAttr(SUMO_ATTR_WIDTH, c->customWidth, c->customWidth == NBEdge::UNSPECIFIED_WIDTH);
329 cdevice.writeOptionalAttr(SUMO_ATTR_TLLINKINDEX, c->customTLIndex, c->customTLIndex == -1);
330 cdevice.writeOptionalAttr(SUMO_ATTR_TLLINKINDEX2, c->customTLIndex2, c->customTLIndex2 == -1);
331 NWWriter_SUMO::writeShape(cdevice, gch, c->customShape, SUMO_ATTR_SHAPE, useGeo, geoAccuracy, c->customShape.size() != 0);
332 NWWriter_SUMO::writeShape(cdevice, gch, c->outlineShape, SUMO_ATTR_OUTLINESHAPE, useGeo, geoAccuracy, c->outlineShape.size() != 0);
333 XMLHelpers::writeParams(cdevice, *c);
334 cdevice.closeTag();
335 }
336 }
337 // write custom walkingarea shapes to the connections file
338 for (std::map<std::string, NBNode*>::const_iterator it_node = nc.begin(); it_node != nc.end(); ++it_node) {
339 for (const auto& wacs : it_node->second->getWalkingAreaCustomShapes()) {
341 cdevice.writeAttr(SUMO_ATTR_NODE, it_node->first);
342 cdevice.writeAttr(SUMO_ATTR_EDGES, joinNamedToString(wacs.edges, " "));
343 NWWriter_SUMO::writeShape(cdevice, gch, wacs.shape, SUMO_ATTR_SHAPE, useGeo, geoAccuracy, wacs.shape.size() != 0);
344 cdevice.writeOptionalAttr(SUMO_ATTR_WIDTH, wacs.width, wacs.width == NBEdge::UNSPECIFIED_WIDTH);
345 cdevice.closeTag();
346 }
347 }
348
349 edevice.close();
350 cdevice.close();
351
352 if (dlrNavteq) {
353 OutputDevice& cdevice2 = OutputDevice::getDevice(prefix + ".cpr." + ext);
354 cdevice2.writeXMLHeader("connections", "connections_file.xsd");
356 cdevice2.close();
357 }
358}
359
360
361void
363 const std::string ext = OptionsCont::getOptions().getString("output.format");
364 std::map<SumoXMLAttr, std::string> attrs;
366 OutputDevice& device = OutputDevice::getDevice(prefix + ".tll." + ext);
367 device.writeXMLHeader("tlLogics", "tllogic_file.xsd", attrs);
369 const bool dlrNavteq = oc.exists("dlr-navteq.plain") && oc.getBool("dlr-navteq.plain");
371 // we also need to remember the associations between tlLogics and connections
372 // since the information in con.xml is insufficient
373 for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
374 NBEdge* e = (*i).second;
375 // write this edge's tl-controlled connections
376 const std::vector<NBEdge::Connection> connections = e->getConnections();
377 for (std::vector<NBEdge::Connection>::const_iterator c = connections.begin(); c != connections.end(); ++c) {
378 if (c->tlID != "") {
380 }
381 }
382 }
383 device.close();
384}
385
386
387void
388NWWriter_XML::writeJoinedJunctions(const std::string& filename, NBNodeCont& nc) {
389 std::map<SumoXMLAttr, std::string> attrs;
391 OutputDevice& device = OutputDevice::getDevice(filename);
392 device.writeXMLHeader("nodes", "nodes_file.xsd", attrs);
393 for (const std::set<std::string>& joined : nc.getJoinedClusters()) {
394 assert(joined.size() > 0);
396 }
397 device.close();
398}
399
400
401void
403 OutputDevice& device = OutputDevice::getDevice(oc.getString("street-sign-output"));
404 device.writeXMLHeader("additional", "additional_file.xsd");
405 for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
406 NBEdge* e = (*i).second;
407 const std::vector<NBSign>& signs = e->getSigns();
408 for (std::vector<NBSign>::const_iterator it = signs.begin(); it != signs.end(); ++it) {
409 it->writeAsPOI(device, e);
410 }
411 }
412 device.close();
413}
414
415
416void
418 OutputDevice& device = OutputDevice::getDevice(oc.getString("ptstop-output"));
419 device.writeXMLHeader("additional", "additional_file.xsd");
420 for (const auto& stopIt : sc.getStops()) {
421 stopIt.second->write(device);
422 }
423 device.close();
424}
425
426
428 OutputDevice& device = OutputDevice::getDevice(oc.getString("ptline-output"));
429 device.writeXMLHeader("ptLines", "ptlines_file.xsd");
430 for (const auto& item : lc.getLines()) {
431 item.second->write(device);
432 }
433 device.close();
434}
435
436
438 OutputDevice& device = OutputDevice::getDevice(oc.getString("parking-output"));
439 device.writeXMLHeader("additional", "additional_file.xsd");
440 for (NBParking& p : pc) {
441 p.write(device, ec);
442 }
443 device.close();
444}
445
446
447void
449 OutputDevice& device = OutputDevice::getDevice(oc.getString("taz-output"));
450 device.writeXMLHeader("additional", "additional_file.xsd");
451 for (std::map<std::string, NBDistrict*>::const_iterator i = dc.begin(); i != dc.end(); i++) {
452 NWWriter_SUMO::writeDistrict(device, *(*i).second);
453 }
454}
455
456
457/****************************************************************************/
#define WRITE_WARNING(msg)
Definition MsgHandler.h:298
#define TL(string)
Definition MsgHandler.h:316
#define TLF(string,...)
Definition MsgHandler.h:318
const SVCPermissions SVCAll
all VClasses are allowed
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PEDESTRIAN
pedestrian
@ SUMO_TAG_JOIN
Join operation.
@ SUMO_TAG_CONNECTION
connectioon between two lanes
@ SUMO_TAG_WALKINGAREA
walking area for pedestrians
@ SUMO_TAG_TYPES
types (edge)
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
@ SUMO_TAG_NODE
alternative definition for junction
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_NEIGH
begin/end of the description of a neighboring lane
@ SUMO_TAG_EDGE
begin/end of the description of an edge
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
@ SUMO_ATTR_NODE
@ SUMO_ATTR_LANE
@ SUMO_ATTR_NODES
a list of node ids, used for controlling joining
@ SUMO_ATTR_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_RADIUS
The turning radius at an intersection in m.
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_FRINGE
Fringe type of node.
@ SUMO_ATTR_BIDI
@ SUMO_ATTR_PRIORITY
@ SUMO_ATTR_NUMLANES
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_TLTYPE
node: the type of traffic light
@ SUMO_ATTR_CHANGE_LEFT
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_NAME
@ SUMO_ATTR_SPREADTYPE
The information about how to spread the lanes from the given position.
@ SUMO_ATTR_ENDOFFSET
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_ROUNDABOUT
Roundabout type of node.
@ SUMO_ATTR_ACCELERATION
@ SUMO_ATTR_CHANGE_RIGHT
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_DISTANCE
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_VERSION
@ SUMO_ATTR_ID
@ SUMO_ATTR_RIGHT_OF_WAY
How to compute right of way.
@ SUMO_ATTR_OUTLINESHAPE
edge: the outline shape in xml-definition
@ SUMO_ATTR_CONTROLLED_INNER
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
@ SUMO_ATTR_KEEP_CLEAR
Whether vehicles must keep the junction clear.
@ SUMO_ATTR_FRICTION
@ SUMO_ATTR_ROUTINGTYPE
int gPrecisionGeo
Definition StdDefs.cpp:29
const MMVersion NETWORK_VERSION(1, 20)
std::string joinNamedToString(const std::set< T *, C > &ns, const T_BETWEEN &between)
Definition ToString.h:374
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:57
static methods for processing the coordinates conversion for the current net
static void writeLocation(OutputDevice &into)
writes the location element
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
bool usingInverseGeoProjection() const
Returns the information whether an inverse transformation will happen.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
A container for districts.
std::map< std::string, NBDistrict * >::const_iterator end() const
Returns the pointer to the end of the stored districts.
std::map< std::string, NBDistrict * >::const_iterator begin() const
Returns the pointer to the begin of the stored districts.
Storage for edges, including some functionality operating on multiple edges.
Definition NBEdgeCont.h:59
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
Definition NBEdgeCont.h:171
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
Definition NBEdgeCont.h:178
std::set< std::string > getUsedTypes() const
return all edge types in used
The representation of a single edge during network building.
Definition NBEdge.h:92
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition NBEdge.cpp:4545
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition NBEdge.h:1047
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
Definition NBEdge.h:608
bool hasLaneSpecificFriction() const
whether lanes differ in friction
Definition NBEdge.cpp:2489
double getLaneWidth() const
Returns the default width of lanes of this edge.
Definition NBEdge.h:648
NBNode * getToNode() const
Returns the destination node of the edge.
Definition NBEdge.h:552
static const double UNSPECIFIED_FRICTION
unspecified lane friction
Definition NBEdge.h:355
const std::vector< NBSign > & getSigns() const
get Signs
Definition NBEdge.h:1486
bool hasLaneSpecificSpeed() const
whether lanes differ in speed
Definition NBEdge.cpp:2479
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition NBEdge.h:789
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
Definition NBEdge.cpp:1022
bool hasLoadedLength() const
Returns whether a length was set explicitly.
Definition NBEdge.h:618
const std::string & getRoutingType() const
return whether this edge should be a bidi edge
Definition NBEdge.h:1454
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition NBEdge.h:736
bool hasLaneSpecificStopOffsets() const
whether lanes differ in stopOffsets
Definition NBEdge.cpp:2532
double getSpeed() const
Returns the speed allowed on this edge.
Definition NBEdge.h:625
const std::string & getID() const
Definition NBEdge.h:1559
double getDistance() const
get distance
Definition NBEdge.h:685
const StopOffset & getEdgeStopOffset() const
Returns the stopOffset to the end of the edge.
Definition NBEdge.cpp:4398
bool hasLaneSpecificPermissions() const
whether lanes differ in allowed vehicle classes
Definition NBEdge.cpp:2465
bool needsLaneSpecificOutput() const
whether at least one lane has values differing from the edges values
Definition NBEdge.cpp:2587
int getNumLanes() const
Returns the number of lanes.
Definition NBEdge.h:526
bool hasLaneSpecificWidth() const
whether lanes differ in width
Definition NBEdge.cpp:2499
double getFriction() const
Returns the friction on this edge.
Definition NBEdge.h:632
bool hasLaneSpecificEndOffset() const
whether lanes differ in offset
Definition NBEdge.cpp:2521
const std::string & getTypeID() const
get ID of type
Definition NBEdge.h:1187
const std::string & getStreetName() const
Returns the street name of this edge.
Definition NBEdge.h:675
const NBEdge * getBidiEdge() const
Definition NBEdge.h:1545
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition NBEdge.h:545
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
Definition NBEdge.cpp:620
int getPriority() const
Returns the priority of the edge.
Definition NBEdge.h:533
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition NBEdge.h:346
double getEndOffset() const
Returns the offset to the destination node.
Definition NBEdge.h:695
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition NBEdge.h:349
Instance responsible for building networks.
NBPTLineCont & getPTLineCont()
Returns a reference to the pt line container.
NBParkingCont & getParkingCont()
NBPTStopCont & getPTStopCont()
Returns a reference to the pt stop container.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBEdgeCont & getEdgeCont()
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
NBTypeCont & getTypeCont()
Returns a reference to the type container.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
Container for nodes during the netbuilding process.
Definition NBNodeCont.h:57
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
Definition NBNodeCont.h:118
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
Definition NBNodeCont.h:123
const std::vector< std::set< std::string > > & getJoinedClusters() const
gets all joined clusters (see doc for myClusters2Join)
Definition NBNodeCont.h:358
Represents a single node (junction) during network building.
Definition NBNode.h:66
RightOfWay getRightOfWay() const
Returns hint on how to compute right of way.
Definition NBNode.h:302
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
Definition NBNode.h:347
static const double UNSPECIFIED_RADIUS
unspecified lane width
Definition NBNode.h:222
FringeType getFringeType() const
Returns fringe type.
Definition NBNode.h:307
SumoXMLNodeType getType() const
Returns the type of this node.
Definition NBNode.h:287
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
Definition NBNode.h:275
bool hasCustomShape() const
return whether the shape was set by the user
Definition NBNode.h:603
const std::string & getName() const
Returns intersection name.
Definition NBNode.h:317
const Position & getPosition() const
Definition NBNode.h:262
const PositionVector & getShape() const
retrieve the junction shape
Definition NBNode.cpp:2792
RoundaboutType getRoundaboutType() const
Returns roundabout type.
Definition NBNode.h:312
double getRadius() const
Returns the turning radius of this node.
Definition NBNode.h:292
bool getKeepClear() const
Returns the keepClear flag.
Definition NBNode.h:297
const std::map< std::string, NBPTLine * > & getLines() const
Container for public transport stops during the net building process.
const std::map< std::string, std::shared_ptr< NBPTStop > > & getStops() const
Returns an unmodifiable reference to the stored pt stops.
The representation of an imported parking area.
Definition NBParking.h:42
The base class for traffic light logic definitions.
A container for traffic light definitions and built programs.
A storage for available edgeTypes of edges.
Definition NBTypeCont.h:52
int size() const
Returns the number of known edgeTypes.
void writeEdgeTypes(OutputDevice &into, const std::set< std::string > &typeIDs=std::set< std::string >()) const
writes all EdgeTypes (and their lanes) as XML
static void writePositionLong(const Position &pos, OutputDevice &dev)
Writes the given position to device in long format (one attribute per dimension)
Definition NWFrame.cpp:216
static void writeEdgeAttrs(OutputDevice &device, const NBEdge *edge)
extra attributes into plain output
static void writeProhibitedManoeuvresAttrs(OutputDevice &device, const NBNodeCont &nc)
static void writeShape(OutputDevice &out, const GeoConvHelper &gch, PositionVector shape, SumoXMLAttr attr, bool useGeo, bool geoAccuracy, bool needsWrite)
static void writeConnection(OutputDevice &into, const NBEdge &from, const NBEdge::Connection &c, bool includeInternal, ConnectionStyle style=SUMONET, bool useGeo=false, bool geoAccuracy=false)
Writes connections outgoing from the given edge (also used in NWWriter_XML)
static void writeProhibitions(OutputDevice &into, const NBConnectionProhibits &prohibitions, const NBEdgeCont &ec)
writes the given prohibitions
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 void writeStopOffsets(OutputDevice &into, const StopOffset &stopOffset)
Write a stopOffset element into output device.
static void writeTrafficLights(OutputDevice &into, const NBTrafficLightLogicCont &tllCont, ConnectionStyle style=SUMONET)
writes the traffic light logics to the given device
static void writeStreetSigns(const OptionsCont &oc, NBEdgeCont &ec)
Writes street signs as POIs to file.
static void writeTrafficLights(const std::string &prefix, NBTrafficLightLogicCont &tc, NBEdgeCont &ec)
Writes the traffic lights file.
static void writeTypes(const std::string &prefix, NBEdgeCont &ec, NBTypeCont &tc)
Writes the types file.
static void writeParkingAreas(const OptionsCont &cont, NBParkingCont &pc, NBEdgeCont &ec)
writes imported parking areas to file
static void writeJoinedJunctions(const std::string &filename, NBNodeCont &nc)
Writes the joined-juncionts to file.
static void writeConfig(const OptionsCont &oc, const std::string &prefix, bool haveTypes)
Writes the configuration file for assempling the network from plain-xml files.
static void writeNetwork(const OptionsCont &oc, const std::string &prefix, NBNetBuilder &nb)
Writes the network into XML-files (nodes, edges, connections, traffic lights)
static void writePTLines(const OptionsCont &cont, NBPTLineCont &lc)
static void writeEdgesAndConnections(const OptionsCont &oc, const std::string &prefix, NBNodeCont &nc, NBEdgeCont &ec)
Writes the edges and connections files.
static void writePTStops(const OptionsCont &oc, NBPTStopCont &ec)
Writes the pt stops file.
static void writeDistricts(const OptionsCont &oc, NBDistrictCont &dc)
writes imported districts (TAZ) to file
static void writeNodes(const OptionsCont &oc, const std::string &prefix, NBNodeCont &nc)
Writes the nodes file.
const std::string & getID() const
Returns the id.
Definition Named.h:73
A storage for options typed value containers)
Definition OptionsCont.h:92
void writeConfiguration(std::ostream &os, const bool filled, const bool complete, const bool addComments, const std::string &relativeTo="", const bool forceRelative=false, const bool inComment=false, const std::string &indent="") const
Writes the configuration.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
OptionsCont * clone() const
make a copy of this OptionsCont instance
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool setDefault(const std::string &name, const std::string &value)
Sets the given value for the named option as new default value.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool set(const std::string &name, const std::string &value, const bool append=false)
Sets the given value for the named option.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
void lf()
writes a line feed if applicable
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
OutputDevice & writeOptionalAttr(const SumoXMLAttr attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute unless null
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
bool isDefined() const
check if stopOffset was defined
T get(const std::string &str) const
get key
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
static OutputDevice & writeParams(OutputDevice &device, const Parameterised &params)
write the parameters of the given object as param tags
static OutputDevice & writePreferences(OutputDevice &device, SVCPermissions preferred)
writes the prefer attribute if needed
static OutputDevice & writePermissions(OutputDevice &device, SVCPermissions permissions)
writes allowed disallowed attributes if needed
A structure which describes a connection between edges or lanes.
Definition NBEdge.h:201
An (internal) definition of a single lane of an edge.
Definition NBEdge.h:143