Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netwrite/NWWriter_XML.cpp
169665 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file NWWriter_XML.cpp
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @author Leonhard Luecken
19
/// @date Tue, 11.05.2011
20
///
21
// Exporter writing networks using XML (native input) format
22
/****************************************************************************/
23
#include <config.h>
24
#include <algorithm>
25
#include <utils/common/MsgHandler.h>
26
#include <utils/common/ToString.h>
27
#include <utils/common/StringUtils.h>
28
#include <utils/options/OptionsCont.h>
29
#include <utils/iodevices/OutputDevice.h>
30
#include <utils/geom/GeoConvHelper.h>
31
#include <netbuild/NBEdge.h>
32
#include <netbuild/NBEdgeCont.h>
33
#include <netbuild/NBNode.h>
34
#include <netbuild/NBNodeCont.h>
35
#include <netbuild/NBNetBuilder.h>
36
#include <netbuild/NBPTLineCont.h>
37
#include <netbuild/NBPTStop.h>
38
#include <netbuild/NBParking.h>
39
#include "NWFrame.h"
40
#include "NWWriter_SUMO.h"
41
#include "NWWriter_XML.h"
42
43
44
// ===========================================================================
45
// method definitions
46
// ===========================================================================
47
// ---------------------------------------------------------------------------
48
// static methods
49
// ---------------------------------------------------------------------------
50
void
51
NWWriter_XML::writeNetwork(const OptionsCont& oc, const std::string& prefix, NBNetBuilder& nb) {
52
// check whether plain-output files shall be generated
53
if (prefix != "") {
54
const bool haveTypes = nb.getTypeCont().size() > 0;
55
writeNodes(oc, prefix, nb.getNodeCont());
56
if (haveTypes) {
57
writeTypes(prefix, nb.getEdgeCont(), nb.getTypeCont());
58
}
59
writeEdgesAndConnections(oc, prefix, nb.getNodeCont(), nb.getEdgeCont());
60
writeTrafficLights(prefix, nb.getTLLogicCont(), nb.getEdgeCont());
61
writeConfig(oc, prefix, haveTypes);
62
}
63
if (oc.isSet("junctions.join-output")) {
64
writeJoinedJunctions(oc.getString("junctions.join-output"), nb.getNodeCont());
65
}
66
if (oc.isSet("street-sign-output")) {
67
writeStreetSigns(oc, nb.getEdgeCont());
68
}
69
if (oc.exists("ptstop-output") && oc.isSet("ptstop-output")) {
70
writePTStops(oc, nb.getPTStopCont());
71
}
72
if (oc.exists("ptline-output") && oc.isSet("ptline-output")) {
73
writePTLines(oc, nb.getPTLineCont());
74
}
75
76
if (oc.exists("parking-output") && oc.isSet("parking-output")) {
77
writeParkingAreas(oc, nb.getParkingCont(), nb.getEdgeCont());
78
}
79
if (oc.exists("taz-output") && oc.isSet("taz-output")) {
80
writeDistricts(oc, nb.getDistrictCont());
81
}
82
}
83
84
85
void
86
NWWriter_XML::writeConfig(const OptionsCont& oc, const std::string& prefix, bool haveTypes) {
87
if (!oc.exists("node-files")) {
88
// do not write configuration for netgen
89
return;
90
}
91
OptionsCont* tmp = oc.clone();
92
tmp->set("node-files", prefix + ".nod.xml");
93
tmp->set("edge-files", prefix + ".edg.xml");
94
tmp->set("connection-files", prefix + ".con.xml");
95
tmp->set("tllogic-files", prefix + ".tll.xml");
96
if (haveTypes) {
97
tmp->set("type-files", prefix + ".typ.xml");
98
}
99
tmp->setDefault("sumo-net-file", "");
100
tmp->setDefault("plain-output-prefix", "");
101
102
const std::string configPath = prefix + ".netccfg";
103
std::ofstream out(configPath.c_str());
104
if (!out.good()) {
105
delete tmp;
106
throw ProcessError(TLF("Could not save configuration to '%'", configPath));
107
} else {
108
tmp->writeConfiguration(out, true, false, false);
109
}
110
delete tmp;
111
}
112
113
114
void
115
NWWriter_XML::writeNodes(const OptionsCont& oc, const std::string& prefix, NBNodeCont& nc) {
116
const GeoConvHelper& gch = GeoConvHelper::getFinal();
117
bool useGeo = oc.exists("proj.plain-geo") && oc.getBool("proj.plain-geo");
118
if (useGeo && !gch.usingGeoProjection()) {
119
WRITE_WARNING(TL("Ignoring option \"proj.plain-geo\" because no geo-conversion has been defined"));
120
useGeo = false;
121
}
122
const bool geoAccuracy = useGeo || gch.usingInverseGeoProjection();
123
124
OutputDevice& device = OutputDevice::getDevice(prefix + ".nod.xml");
125
std::map<SumoXMLAttr, std::string> attrs;
126
attrs[SUMO_ATTR_VERSION] = toString(NETWORK_VERSION);
127
device.writeXMLHeader("nodes", "nodes_file.xsd", attrs);
128
129
// write network offsets and projection to allow reconstruction of original coordinates
130
if (!useGeo) {
131
GeoConvHelper::writeLocation(device);
132
}
133
134
// write nodes
135
TrafficLightType tlsDefaultType = SUMOXMLDefinitions::TrafficLightTypes.get(oc.getString("tls.default-type"));
136
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
137
NBNode* n = (*i).second;
138
device.openTag(SUMO_TAG_NODE);
139
device.writeAttr(SUMO_ATTR_ID, n->getID());
140
// write position
141
Position pos = n->getPosition();
142
if (useGeo) {
143
gch.cartesian2geo(pos);
144
}
145
if (geoAccuracy) {
146
device.setPrecision(gPrecisionGeo);
147
}
148
NWFrame::writePositionLong(pos, device);
149
if (geoAccuracy) {
150
device.setPrecision();
151
}
152
153
device.writeAttr(SUMO_ATTR_TYPE, toString(n->getType()));
154
if (n->isTLControlled()) {
155
// set may contain multiple programs for the same id.
156
// make sure ids are unique and sorted
157
std::set<std::string> tlsIDs;
158
std::set<std::string> controlledInnerEdges;
159
std::string tlType = "";
160
for (NBTrafficLightDefinition* tl : n->getControllingTLS()) {
161
tlsIDs.insert(tl->getID());
162
std::vector<std::string> cie = tl->getControlledInnerEdges();
163
controlledInnerEdges.insert(cie.begin(), cie.end());
164
if (tl->getType() != tlsDefaultType) {
165
tlType = toString(tl->getType());
166
}
167
}
168
std::vector<std::string> sortedIDs(tlsIDs.begin(), tlsIDs.end());
169
sort(sortedIDs.begin(), sortedIDs.end());
170
device.writeAttr(SUMO_ATTR_TLID, sortedIDs);
171
if (tlType != "") {
172
device.writeAttr(SUMO_ATTR_TLTYPE, tlType);
173
}
174
if (controlledInnerEdges.size() > 0) {
175
std::vector<std::string> sortedCIEs(controlledInnerEdges.begin(), controlledInnerEdges.end());
176
sort(sortedCIEs.begin(), sortedCIEs.end());
177
device.writeAttr(SUMO_ATTR_CONTROLLED_INNER, joinToString(sortedCIEs, " "));
178
}
179
}
180
if (n->hasCustomShape()) {
181
writeShape(device, gch, n->getShape(), SUMO_ATTR_SHAPE, useGeo, geoAccuracy);
182
}
183
if (n->getRadius() != NBNode::UNSPECIFIED_RADIUS) {
184
device.writeAttr(SUMO_ATTR_RADIUS, n->getRadius());
185
}
186
if (!n->getKeepClear()) {
187
device.writeAttr<bool>(SUMO_ATTR_KEEP_CLEAR, n->getKeepClear());
188
}
189
if (n->getRightOfWay() != RightOfWay::DEFAULT) {
190
device.writeAttr<std::string>(SUMO_ATTR_RIGHT_OF_WAY, toString(n->getRightOfWay()));
191
}
192
if (n->getFringeType() != FringeType::DEFAULT) {
193
device.writeAttr<std::string>(SUMO_ATTR_FRINGE, toString(n->getFringeType()));
194
}
195
if (n->getName() != "") {
196
device.writeAttr<std::string>(SUMO_ATTR_NAME, StringUtils::escapeXML(n->getName()));
197
}
198
n->writeParams(device);
199
device.closeTag();
200
}
201
device.close();
202
}
203
204
205
void
206
NWWriter_XML::writeTypes(const std::string& prefix, NBEdgeCont& ec, NBTypeCont& tc) {
207
OutputDevice& device = OutputDevice::getDevice(prefix + ".typ.xml");
208
std::map<SumoXMLAttr, std::string> attrs;
209
attrs[SUMO_ATTR_VERSION] = toString(NETWORK_VERSION);
210
device.writeXMLHeader(toString(SUMO_TAG_TYPES), "types_file.xsd", attrs);
211
std::set<std::string> usedTypes = ec.getUsedTypes();
212
tc.writeEdgeTypes(device, usedTypes);
213
device.close();
214
}
215
216
217
void
218
NWWriter_XML::writeEdgesAndConnections(const OptionsCont& oc, const std::string& prefix, NBNodeCont& nc, NBEdgeCont& ec) {
219
const GeoConvHelper& gch = GeoConvHelper::getFinal();
220
bool useGeo = oc.exists("proj.plain-geo") && oc.getBool("proj.plain-geo");
221
const bool geoAccuracy = useGeo || gch.usingInverseGeoProjection();
222
223
std::map<SumoXMLAttr, std::string> attrs;
224
attrs[SUMO_ATTR_VERSION] = toString(NETWORK_VERSION);
225
OutputDevice& edevice = OutputDevice::getDevice(prefix + ".edg.xml");
226
edevice.writeXMLHeader("edges", "edges_file.xsd", attrs);
227
OutputDevice& cdevice = OutputDevice::getDevice(prefix + ".con.xml");
228
cdevice.writeXMLHeader("connections", "connections_file.xsd", attrs);
229
const bool writeNames = oc.getBool("output.street-names");
230
const bool writeLanes = oc.getBool("plain-output.lanes");
231
232
// write network offsets and projection to allow reconstruction of original coordinates at least for geo-referenced networks
233
if (!useGeo && gch.usingGeoProjection()) {
234
GeoConvHelper::writeLocation(edevice);
235
}
236
LaneSpreadFunction defaultSpread = SUMOXMLDefinitions::LaneSpreadFunctions.get(oc.getString("default.spreadtype"));
237
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
238
// write the edge itself to the edges-files
239
NBEdge* e = (*i).second;
240
edevice.openTag(SUMO_TAG_EDGE);
241
edevice.writeAttr(SUMO_ATTR_ID, e->getID());
242
edevice.writeAttr(SUMO_ATTR_FROM, e->getFromNode()->getID());
243
edevice.writeAttr(SUMO_ATTR_TO, e->getToNode()->getID());
244
if (writeNames && e->getStreetName() != "") {
245
edevice.writeAttr(SUMO_ATTR_NAME, StringUtils::escapeXML(e->getStreetName()));
246
}
247
edevice.writeAttr(SUMO_ATTR_PRIORITY, e->getPriority());
248
// write the type if given
249
if (e->getTypeID() != "") {
250
edevice.writeAttr(SUMO_ATTR_TYPE, e->getTypeID());
251
}
252
edevice.writeAttr(SUMO_ATTR_NUMLANES, e->getNumLanes());
253
if (!e->hasLaneSpecificSpeed()) {
254
edevice.writeAttr(SUMO_ATTR_SPEED, e->getSpeed());
255
}
256
if (!e->hasLaneSpecificFriction()) {
257
if (e->getFriction() != NBEdge::UNSPECIFIED_FRICTION) {
258
edevice.writeAttr(SUMO_ATTR_FRICTION, e->getFriction());
259
}
260
}
261
// write non-default geometry
262
if (!e->hasDefaultGeometry()) {
263
writeShape(edevice, gch, e->getGeometry(), SUMO_ATTR_SHAPE, useGeo, geoAccuracy);
264
}
265
// write the spread type if not default ("right")
266
if (e->getLaneSpreadFunction() != defaultSpread) {
267
edevice.writeAttr(SUMO_ATTR_SPREADTYPE, toString(e->getLaneSpreadFunction()));
268
}
269
// write the length if it was specified
270
if (e->hasLoadedLength()) {
271
edevice.writeAttr(SUMO_ATTR_LENGTH, e->getLoadedLength());
272
}
273
// some attributes can be set by edge default or per lane. Write as default if possible (efficiency)
274
if (e->getLaneWidth() != NBEdge::UNSPECIFIED_WIDTH && !e->hasLaneSpecificWidth()) {
275
edevice.writeAttr(SUMO_ATTR_WIDTH, e->getLaneWidth());
276
}
277
if (e->getEndOffset() != NBEdge::UNSPECIFIED_OFFSET && !e->hasLaneSpecificEndOffset()) {
278
edevice.writeAttr(SUMO_ATTR_ENDOFFSET, e->getEndOffset());
279
}
280
if (!e->hasLaneSpecificPermissions()) {
281
writePermissions(edevice, e->getPermissions(0));
282
}
283
if (!e->hasLaneSpecificStopOffsets() && e->getEdgeStopOffset().isDefined()) {
284
NWWriter_SUMO::writeStopOffsets(edevice, e->getEdgeStopOffset());
285
}
286
if (e->getDistance() != 0) {
287
edevice.writeAttr(SUMO_ATTR_DISTANCE, e->getDistance());
288
}
289
if (e->getBidiEdge() != 0) {
290
edevice.writeAttr(SUMO_ATTR_BIDI, e->getBidiEdge()->getID());
291
}
292
if (e->needsLaneSpecificOutput() || writeLanes) {
293
int idx = 0;
294
for (const NBEdge::Lane& lane : e->getLanes()) {
295
edevice.openTag(SUMO_TAG_LANE);
296
edevice.writeAttr(SUMO_ATTR_INDEX, idx++);
297
// write allowed lanes
298
if (e->hasLaneSpecificPermissions() || writeLanes) {
299
writePermissions(edevice, lane.permissions);
300
}
301
writePreferences(edevice, lane.preferred);
302
// write other attributes
303
if (lane.width != NBEdge::UNSPECIFIED_WIDTH && (e->hasLaneSpecificWidth() || writeLanes)) {
304
edevice.writeAttr(SUMO_ATTR_WIDTH, lane.width);
305
}
306
if (lane.endOffset != NBEdge::UNSPECIFIED_OFFSET && (e->hasLaneSpecificEndOffset() || writeLanes)) {
307
edevice.writeAttr(SUMO_ATTR_ENDOFFSET, lane.endOffset);
308
}
309
if (e->hasLaneSpecificSpeed() || writeLanes) {
310
edevice.writeAttr(SUMO_ATTR_SPEED, lane.speed);
311
}
312
if (lane.accelRamp) {
313
edevice.writeAttr(SUMO_ATTR_ACCELERATION, lane.accelRamp);
314
}
315
if (lane.customShape.size() > 0 || writeLanes) {
316
writeShape(edevice, gch, lane.customShape.size() > 0 ? lane.customShape : lane.shape, SUMO_ATTR_SHAPE, useGeo, geoAccuracy);
317
}
318
if (lane.type != "") {
319
edevice.writeAttr(SUMO_ATTR_TYPE, lane.type);
320
}
321
if (lane.changeLeft != SVCAll && lane.changeLeft != SVC_UNSPECIFIED && lane.changeLeft != SVC_IGNORING) {
322
edevice.writeAttr(SUMO_ATTR_CHANGE_LEFT, getVehicleClassNames(lane.changeLeft));
323
}
324
if (lane.changeRight != SVCAll && lane.changeRight != SVC_UNSPECIFIED && lane.changeRight != SVC_IGNORING) {
325
edevice.writeAttr(SUMO_ATTR_CHANGE_RIGHT, getVehicleClassNames(lane.changeRight));
326
}
327
if (lane.oppositeID != "") {
328
edevice.openTag(SUMO_TAG_NEIGH);
329
edevice.writeAttr(SUMO_ATTR_LANE, lane.oppositeID);
330
edevice.closeTag();
331
}
332
lane.writeParams(edevice);
333
NWWriter_SUMO::writeStopOffsets(edevice, lane.laneStopOffset);
334
edevice.closeTag();
335
}
336
}
337
e->writeParams(edevice);
338
edevice.closeTag();
339
// write this edge's connections to the connections-files
340
const std::vector<NBEdge::Connection> connections = e->getConnections();
341
if (connections.empty()) {
342
// if there are no connections and this appears to be customized, preserve the information
343
const int numOutgoing = (int)e->getToNode()->getOutgoingEdges().size();
344
if (numOutgoing > 0) {
345
const SVCPermissions inPerm = e->getPermissions();
346
SVCPermissions outPerm = 0;
347
for (auto out : e->getToNode()->getOutgoingEdges()) {
348
outPerm |= out->getPermissions();
349
}
350
if ((inPerm & outPerm) != 0 && (inPerm & outPerm) != SVC_PEDESTRIAN) {
351
cdevice.openTag(SUMO_TAG_CONNECTION);
352
cdevice.writeAttr(SUMO_ATTR_FROM, e->getID());
353
cdevice.closeTag();
354
cdevice << "\n";
355
}
356
}
357
} else {
358
for (NBEdge::Connection c : connections) {
359
if (useGeo) {
360
for (Position& p : c.customShape) {
361
gch.cartesian2geo(p);
362
}
363
}
364
NWWriter_SUMO::writeConnection(cdevice, *e, c, false, NWWriter_SUMO::PLAIN, geoAccuracy);
365
}
366
cdevice << "\n";
367
}
368
}
369
// write roundabout information to the edges-files
370
if (ec.getRoundabouts().size() > 0) {
371
edevice.lf();
372
NWWriter_SUMO::writeRoundabouts(edevice, ec.getRoundabouts(), ec);
373
}
374
375
// write loaded prohibitions to the connections-file
376
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
377
NWWriter_SUMO::writeProhibitions(cdevice, i->second->getProhibitions());
378
}
379
// write pedestrian crossings to the connections-file
380
for (std::map<std::string, NBNode*>::const_iterator it_node = nc.begin(); it_node != nc.end(); ++it_node) {
381
const std::vector<NBNode::Crossing*>& crossings = (*it_node).second->getCrossings();
382
for (auto c : crossings) {
383
cdevice.openTag(SUMO_TAG_CROSSING);
384
cdevice.writeAttr(SUMO_ATTR_NODE, (*it_node).second->getID());
385
cdevice.writeAttr(SUMO_ATTR_EDGES, c->edges);
386
cdevice.writeAttr(SUMO_ATTR_PRIORITY, c->priority);
387
if (c->customWidth != NBEdge::UNSPECIFIED_WIDTH) {
388
cdevice.writeAttr(SUMO_ATTR_WIDTH, c->customWidth);
389
}
390
if (c->customTLIndex != -1) {
391
cdevice.writeAttr(SUMO_ATTR_TLLINKINDEX, c->customTLIndex);
392
}
393
if (c->customTLIndex2 != -1) {
394
cdevice.writeAttr(SUMO_ATTR_TLLINKINDEX2, c->customTLIndex2);
395
}
396
if (c->customShape.size() != 0) {
397
writeShape(cdevice, gch, c->customShape, SUMO_ATTR_SHAPE, useGeo, geoAccuracy);
398
}
399
if (c->outlineShape.size() != 0) {
400
writeShape(cdevice, gch, c->outlineShape, SUMO_ATTR_OUTLINESHAPE, useGeo, geoAccuracy);
401
}
402
c->writeParams(cdevice);
403
cdevice.closeTag();
404
}
405
}
406
// write custom walkingarea shapes to the connections file
407
for (std::map<std::string, NBNode*>::const_iterator it_node = nc.begin(); it_node != nc.end(); ++it_node) {
408
for (const auto& wacs : it_node->second->getWalkingAreaCustomShapes()) {
409
cdevice.openTag(SUMO_TAG_WALKINGAREA);
410
cdevice.writeAttr(SUMO_ATTR_NODE, it_node->first);
411
cdevice.writeAttr(SUMO_ATTR_EDGES, joinNamedToString(wacs.edges, " "));
412
if (wacs.shape.size() != 0) {
413
writeShape(cdevice, gch, wacs.shape, SUMO_ATTR_SHAPE, useGeo, geoAccuracy);
414
}
415
if (wacs.width != NBEdge::UNSPECIFIED_WIDTH) {
416
cdevice.writeAttr(SUMO_ATTR_WIDTH, wacs.width);
417
}
418
cdevice.closeTag();
419
}
420
}
421
422
edevice.close();
423
cdevice.close();
424
}
425
426
427
void
428
NWWriter_XML::writeTrafficLights(const std::string& prefix, NBTrafficLightLogicCont& tc, NBEdgeCont& ec) {
429
std::map<SumoXMLAttr, std::string> attrs;
430
attrs[SUMO_ATTR_VERSION] = toString(NETWORK_VERSION);
431
OutputDevice& device = OutputDevice::getDevice(prefix + ".tll.xml");
432
device.writeXMLHeader("tlLogics", "tllogic_file.xsd", attrs);
433
NWWriter_SUMO::writeTrafficLights(device, tc);
434
// we also need to remember the associations between tlLogics and connections
435
// since the information in con.xml is insufficient
436
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
437
NBEdge* e = (*i).second;
438
// write this edge's tl-controlled connections
439
const std::vector<NBEdge::Connection> connections = e->getConnections();
440
for (std::vector<NBEdge::Connection>::const_iterator c = connections.begin(); c != connections.end(); ++c) {
441
if (c->tlID != "") {
442
NWWriter_SUMO::writeConnection(device, *e, *c, false, NWWriter_SUMO::TLL);
443
}
444
}
445
}
446
device.close();
447
}
448
449
450
void
451
NWWriter_XML::writeJoinedJunctions(const std::string& filename, NBNodeCont& nc) {
452
std::map<SumoXMLAttr, std::string> attrs;
453
attrs[SUMO_ATTR_VERSION] = toString(NETWORK_VERSION);
454
OutputDevice& device = OutputDevice::getDevice(filename);
455
device.writeXMLHeader("nodes", "nodes_file.xsd", attrs);
456
const std::vector<std::set<std::string> >& clusters = nc.getJoinedClusters();
457
for (std::vector<std::set<std::string> >::const_iterator it = clusters.begin(); it != clusters.end(); it++) {
458
assert((*it).size() > 0);
459
device.openTag(SUMO_TAG_JOIN);
460
// prepare string
461
std::ostringstream oss;
462
for (std::set<std::string>::const_iterator it_id = it->begin(); it_id != it->end(); it_id++) {
463
oss << *it_id << " ";
464
}
465
// remove final space
466
std::string ids = oss.str();
467
device.writeAttr(SUMO_ATTR_NODES, ids.substr(0, ids.size() - 1));
468
device.closeTag();
469
}
470
device.close();
471
}
472
473
474
void
475
NWWriter_XML::writeStreetSigns(const OptionsCont& oc, NBEdgeCont& ec) {
476
OutputDevice& device = OutputDevice::getDevice(oc.getString("street-sign-output"));
477
device.writeXMLHeader("additional", "additional_file.xsd");
478
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
479
NBEdge* e = (*i).second;
480
const std::vector<NBSign>& signs = e->getSigns();
481
for (std::vector<NBSign>::const_iterator it = signs.begin(); it != signs.end(); ++it) {
482
it->writeAsPOI(device, e);
483
}
484
}
485
device.close();
486
}
487
488
489
void
490
NWWriter_XML::writePTStops(const OptionsCont& oc, NBPTStopCont& sc) {
491
OutputDevice& device = OutputDevice::getDevice(oc.getString("ptstop-output"));
492
device.writeXMLHeader("additional", "additional_file.xsd");
493
for (const auto& stopIt : sc.getStops()) {
494
stopIt.second->write(device);
495
}
496
device.close();
497
}
498
499
500
void NWWriter_XML::writePTLines(const OptionsCont& oc, NBPTLineCont& lc) {
501
OutputDevice& device = OutputDevice::getDevice(oc.getString("ptline-output"));
502
device.writeXMLHeader("ptLines", "ptlines_file.xsd");
503
for (const auto& item : lc.getLines()) {
504
item.second->write(device);
505
}
506
device.close();
507
}
508
509
510
void NWWriter_XML::writeParkingAreas(const OptionsCont& oc, NBParkingCont& pc, NBEdgeCont& ec) {
511
OutputDevice& device = OutputDevice::getDevice(oc.getString("parking-output"));
512
device.writeXMLHeader("additional", "additional_file.xsd");
513
for (NBParking& p : pc) {
514
p.write(device, ec);
515
}
516
device.close();
517
}
518
519
520
void
521
NWWriter_XML::writeDistricts(const OptionsCont& oc, NBDistrictCont& dc) {
522
OutputDevice& device = OutputDevice::getDevice(oc.getString("taz-output"));
523
device.writeXMLHeader("additional", "additional_file.xsd");
524
for (std::map<std::string, NBDistrict*>::const_iterator i = dc.begin(); i != dc.end(); i++) {
525
NWWriter_SUMO::writeDistrict(device, *(*i).second);
526
}
527
}
528
529
530
void
531
NWWriter_XML::writeShape(OutputDevice& out, const GeoConvHelper& gch, PositionVector shape, SumoXMLAttr attr, bool useGeo, bool geoAccuracy) {
532
if (useGeo) {
533
for (int i = 0; i < (int) shape.size(); i++) {
534
gch.cartesian2geo(shape[i]);
535
}
536
}
537
if (geoAccuracy) {
538
out.setPrecision(gPrecisionGeo);
539
}
540
out.writeAttr(attr, shape);
541
if (geoAccuracy) {
542
out.setPrecision();
543
}
544
}
545
546
547
/****************************************************************************/
548
549