46 #ifdef CHECK_MEMORY_LEAKS
48 #endif // CHECK_MEMORY_LEAKS
61 if (!oc.
isSet(
"opendrive-output")) {
71 device <<
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
72 device <<
"<OpenDRIVE>\n";
74 std::string dstr(ctime(&now));
78 device <<
" <header revMajor=\"1\" revMinor=\"3\" name=\"\" version=\"1.00\" date=\"" << dstr.substr(0, dstr.length() - 1)
79 <<
"\" north=\"" << b.
ymax() <<
"\" south=\"" << b.
ymin() <<
"\" east=\"" << b.
xmax() <<
"\" west=\"" << b.
xmin()
80 <<
"\" maxRoad=\"" << ec.
size() <<
"\" maxJunc=\"" << nc.
size() <<
"\" maxPrg=\"0\"/>\n";
82 for (std::map<std::string, NBEdge*>::const_iterator i = ec.
begin(); i != ec.
end(); ++i) {
83 const NBEdge* e = (*i).second;
85 device <<
" <link>\n";
86 device <<
" <predecessor elementType=\"junction\" elementId=\"" <<
getID(e->
getFromNode()->
getID(), nodeMap, nodeID) <<
"\"/>\n";
87 device <<
" <successor elementType=\"junction\" elementId=\"" <<
getID(e->
getToNode()->
getID(), nodeMap, nodeID) <<
"\"/>\n";
88 device <<
" </link>\n";
89 device <<
" <type s=\"0\" type=\"town\"/>\n";
90 const std::vector<NBEdge::Lane>& lanes = e->
getLanes();
91 unsigned int li = (
unsigned int)lanes.size() - 1;
96 device <<
" <elevationProfile><elevation s=\"0\" a=\"0\" b=\"0\" c=\"0\" d=\"0\"/></elevationProfile>\n";
97 device <<
" <lateralProfile/>\n";
98 device <<
" <lanes>\n";
99 device <<
" <laneSection s=\"0\">\n";
101 device <<
" <right>\n";
103 device <<
" <lane id=\"-" << e->
getNumLanes() - j <<
"\" type=\"driving\" level=\"0\">\n";
104 device <<
" <link>\n";
105 device <<
" <predecessor id=\"-1\"/>\n";
106 device <<
" <successor id=\"-1\"/>\n";
107 device <<
" </link>\n";
109 device <<
" <width sOffset=\"0\" a=\"" << width <<
"\" b=\"0\" c=\"0\" d=\"0\"/>\n";
110 std::string markType =
"broken";
114 device <<
" <roadMark sOffset=\"0\" type=\"" << markType <<
"\" weight=\"standard\" color=\"standard\" width=\"0.13\"/>\n";
115 device <<
" </lane>\n";
117 device <<
" </right>\n";
118 device <<
" </laneSection>\n";
119 device <<
" </lanes>\n";
120 device <<
" <objects/>\n";
121 device <<
" <signals/>\n";
122 device <<
" </road>\n";
126 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
129 for (std::vector<NBEdge*>::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
130 const std::vector<NBEdge::Connection>& elv = (*j)->getConnections();
131 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
132 if ((*k).toEdge == 0) {
143 if (shape.
length() != 0) {
146 WRITE_WARNING(
"Same position problem at internal edge '" + c.
id +
"'.");
148 device <<
" <road name=\"" << c.
id <<
"\" length=\"" << shape.
length() <<
"\" id=\"" <<
getID(c.
id, edgeMap, edgeID) <<
"\" junction=\"" <<
getID(n->
getID(), nodeMap, nodeID) <<
"\">\n";
149 device <<
" <link>\n";
150 device <<
" <predecessor elementType=\"road\" elementId=\"" <<
getID((*j)->getID(), edgeMap, edgeID) <<
"\"/>\n";
151 device <<
" <successor elementType=\"road\" elementId=\"" <<
getID((*k).toEdge->getID(), edgeMap, edgeID) <<
"\"/>\n";
152 device <<
" </link>\n";
153 device <<
" <type s=\"0\" type=\"town\"/>\n";
155 device <<
" <elevationProfile><elevation s=\"0\" a=\"0\" b=\"0\" c=\"0\" d=\"0\"/></elevationProfile>\n";
156 device <<
" <lateralProfile/>\n";
157 device <<
" <lanes>\n";
158 device <<
" <laneSection s=\"0\">\n";
160 device <<
" <right>\n";
161 device <<
" <lane id=\"-1\" type=\"driving\" level=\"0\">\n";
162 device <<
" <link>\n";
163 device <<
" <predecessor id=\"-" << (*j)->getNumLanes() - c.
fromLane <<
"\"/>\n";
165 device <<
" </link>\n";
166 device <<
" <width sOffset=\"0\" a=\"" << width <<
"\" b=\"0\" c=\"0\" d=\"0\"/>\n";
167 device <<
" <roadMark sOffset=\"0\" type=\"none\" weight=\"standard\" color=\"standard\" width=\"0.13\"/>\n";
168 device <<
" </lane>\n";
169 device <<
" </right>\n";
170 device <<
" </laneSection>\n";
171 device <<
" </lanes>\n";
172 device <<
" <objects/>\n";
173 device <<
" <signals/>\n";
174 device <<
" </road>\n";
180 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
182 device <<
" <junction name=\"" << n->
getID() <<
"\" id=\"" <<
getID(n->
getID(), nodeMap, nodeID) <<
"\">\n";
183 unsigned int index = 0;
185 for (std::vector<NBEdge*>::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
186 const std::vector<NBEdge::Connection>& elv = (*j)->getConnections();
187 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
188 if ((*k).toEdge == 0) {
191 device <<
" <connection id=\"" << index <<
"\" incomingRoad=\"" <<
getID((*j)->getID(), edgeMap, edgeID)
192 <<
"\" connectingRoad=\"" <<
getID((*k).id, edgeMap, edgeID) <<
"\" contactPoint=\"start\"/>\n";
196 device <<
" </junction>\n";
199 device <<
"</OpenDRIVE>\n";
206 device <<
" <planView>\n";
208 for (
unsigned int j = 0; j < shape.
size() - 1; ++j) {
212 device <<
" <geometry s=\"" << offset <<
"\" x=\"" << p.
x() <<
"\" y=\"" << p.
y() <<
"\" hdg=\"" << hdg <<
"\" length=\"" << l.
length() <<
"\"><line/></geometry>\n";
215 device <<
" </planView>\n";
221 device <<
" <center>\n";
222 device <<
" <lane id=\"0\" type=\"none\" level= \"0\">\n";
223 device <<
" <link/>\n";
224 device <<
" <roadMark sOffset=\"0\" type=\"" << mark <<
"\" weight=\"standard\" color=\"standard\" width=\"" << markWidth <<
"\"/>\n";
225 device <<
" <width sOffset=\"0\" a=\"0\" b=\"0\" c=\"0\" d=\"0\"/>\n";
226 device <<
" </lane>\n";
227 device <<
" </center>\n";
234 return map.
get(origID);
236 map.
insert(origID, lastID++);