45#define MIN_TURN_DIAMETER 2.0
47#define ROAD_OBJECTS "roadObjects"
65 if (!oc.
isSet(
"opendrive-output")) {
70 const bool origNames = oc.
getBool(
"output.original-names");
74 const double straightThresh =
DEG2RAD(oc.
getFloat(
"opendrive-output.straight-threshold"));
77 int edgeID = nc.
size() * 10;
83 time_t now = time(
nullptr);
84 std::string dstr(ctime(&now));
92 device.
writeAttr(
"date", dstr.substr(0, dstr.length() - 1));
105 device.
openTag(
"geoReference");
126 std::map<std::string, std::vector<std::string>> crosswalksByEdge;
127 for (
auto it = nc.
begin(); it != nc.
end(); ++it) {
132 crosswalk_shape = cw->shape;
135 crosswalk_shape.
move2side(cw->width / 2);
138 rightside = rightside.
reverse();
139 crosswalk_shape.
append(rightside);
140 auto crosswalkId = cw->id;
143 crosswalk_shape,
false,
true, 1,
false, crosswalkId);
148 crosswalksByEdge[cw->edges[0]->getID()].push_back(crosswalkId);
153 for (std::map<std::string, NBEdge*>::const_iterator i = ec.
begin(); i != ec.
end(); ++i) {
154 const NBEdge* e = (*i).second;
159 fromNodeID, toNodeID,
160 origNames, straightThresh,
163 crosswalksByEdge[e->
getID()]);
169 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
171 int connectionID = 0;
172 const int nID =
getID(n->
getID(), nodeMap, nodeID);
174 junctionOSS <<
" <junction name=\"" << n->
getID() <<
"\" id=\"" << nID <<
"\">\n";
176 std::vector<NBEdge*> incoming = (*i).second->getIncomingEdges();
178 std::reverse(incoming.begin(), incoming.end());
180 for (
NBEdge* inEdge : incoming) {
181 std::string centerMark =
"none";
182 const int inEdgeID =
getID(inEdge->getID(), edgeMap, edgeID);
184 const NBEdge* outEdge =
nullptr;
185 bool isOuterEdge =
true;
186 int lastFromLane = -1;
187 std::vector<NBEdge::Connection> parallel;
188 std::vector<NBEdge::Connection> connections = inEdge->
getConnections();
190 assert(c.toEdge != 0);
191 if (outEdge != c.toEdge || c.fromLane == lastFromLane) {
192 if (outEdge !=
nullptr) {
197 getID(parallel.back().getInternalLaneID(), edgeMap, edgeID),
201 parallel, isOuterEdge, straightThresh, centerMark,
208 lastFromLane = c.fromLane;
209 parallel.push_back(c);
214 if (!parallel.empty()) {
216 centerMark =
"solid";
219 getID(parallel.back().getInternalLaneID(), edgeMap, edgeID),
223 parallel, isOuterEdge, straightThresh, centerMark,
229 junctionOSS <<
" </junction>\n";
234 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
238 std::set<std::string> ids;
242 const std::string
id = tl->
getID() +
"_" +
toString(c.getTLIndex());
243 if (ids.count(
id) == 0) {
263 std::map<std::string, std::string> dividerTypeMapping;
264 dividerTypeMapping[
"solid_line"] =
"solid";
265 dividerTypeMapping[
"dashed_line"] =
"broken";
266 dividerTypeMapping[
"double_solid_line"] =
"solid solid";
267 dividerTypeMapping[
"no"] =
"none";
270 std::string dividerType =
"solid";
274 if (dividerTypeMapping.count(divider) > 0) {
275 dividerType = dividerTypeMapping.find(divider)->second;
284 int edgeID,
int fromNodeID,
int toNodeID,
285 const bool origNames,
286 const double straightThresh,
289 const std::vector<std::string>& crossings) {
297 planViewOSS.
openTag(
"planView");
299 const std::vector<NBEdge::Lane>& lanes = e->
getLanes();
301#ifdef DEBUG_SMOOTH_GEOM
303 std::cout <<
"write planview for edge " << e->
getID() <<
"\n";
329 device.
writeAttr(
"elementType",
"junction");
330 device.
writeAttr(
"elementId", fromNodeID);
335 device.
writeAttr(
"elementType",
"junction");
344 device <<
" <lateralProfile/>\n";
345 device <<
" <lanes>\n";
346 device <<
" <laneSection s=\"0\">\n";
351 const std::string side =
LHLL ?
"left" :
"right";
352 device <<
" <" << side <<
">\n";
354 for (
int jRH = numLanes; --jRH >= 0;) {
357 const int j =
lefthand ? numLanes - 1 - jRH : jRH;
359 if (laneType ==
"") {
362 device <<
" <lane id=\"" <<
s2x(j, numLanes) <<
"\" type=\"" << laneType <<
"\" level=\"true\">\n";
363 device <<
" <link/>\n";
371 device <<
" <width sOffset=\"0\" a=\"" << e->
getLaneWidth(j) <<
"\" b=\"0\" c=\"0\" d=\"0\"/>\n";
372 std::string markType =
"broken";
374 if (j == numLanes - 1) {
393 device <<
" <roadMark sOffset=\"0\" type=\"" << markType <<
"\" weight=\"standard\" color=\"standard\" width=\"0.13\"/>\n";
394 device <<
" <speed sOffset=\"0\" max=\"" << lanes[j].speed <<
"\"/>\n";
395 device <<
" </lane>\n";
397 device <<
" </" << side <<
">\n";
401 device <<
" </laneSection>\n";
402 device <<
" </lanes>\n";
406 device <<
" <userData code=\"sumoId\" value=\"" << e->
getID() <<
"\"/>\n";
416 if (outEdge !=
nullptr
420 || parallel.front().fromLane != 0
421 || parallel.front().toLane != 0)) {
423 parallel.front().vmax = (inEdge->
getLanes()[0].speed + outEdge->
getLanes()[0].speed) / (
double) 2.0;
430 int edgeID,
int inEdgeID,
int outEdgeID,
432 const std::vector<NBEdge::Connection>& parallel,
433 const bool isOuterEdge,
434 const double straightThresh,
435 const std::string& centerMark,
437 assert(parallel.size() != 0);
445 double laneOffset = 0;
447 fallBackShape.push_back(begShape.back());
448 fallBackShape.push_back(endShape.front());
452 if (init.size() == 0) {
457 }
else if (length <= NUMERICAL_EPS) {
463 if (init.size() != 0) {
472 double roadLength =
MAX2(POSITION_EPS, length);
474 junctionDevice <<
" <connection id=\"" << connectionID <<
"\" incomingRoad=\"" << inEdgeID <<
"\" connectingRoad=\"" << edgeID <<
"\" contactPoint=\"start\">\n";
490 device.
writeAttr(
"elementId", outEdgeID);
491 device.
writeAttr(
"contactPoint",
"start");
499#ifdef DEBUG_SMOOTH_GEOM
501 std::cout <<
"write planview for internal edge " << cLeft.
id <<
" init=" << init <<
" fallback=" << fallBackShape
502 <<
" begShape=" << begShape <<
" endShape=" << endShape
506 if (init.size() == 0) {
514 device <<
" <lateralProfile/>\n";
515 device <<
" <lanes>\n";
516 if (laneOffset != 0) {
517 device <<
" <laneOffset s=\"0\" a=\"" << laneOffset <<
"\" b=\"0\" c=\"0\" d=\"0\"/>\n";
519 device <<
" <laneSection s=\"0\">\n";
523 const std::string side =
lefthand ?
"left" :
"right";
524 device <<
" <" << side <<
">\n";
525 const int numLanes = (int)parallel.size();
526 for (
int jRH = numLanes; --jRH >= 0;) {
527 const int j =
lefthand ? numLanes - 1 - jRH : jRH;
528 const int xJ =
s2x(j, numLanes);
538 double bCoefficient = (outEdgeWidth - inEdgeWidth) / roadLength;
539 double cCoefficient = 0;
540 double dCoefficient = 0;
542 device <<
" <link>\n";
543 device <<
" <predecessor id=\"" << fromIndex <<
"\"/>\n";
544 device <<
" <successor id=\"" << toIndex <<
"\"/>\n";
545 device <<
" </link>\n";
546 device <<
" <width sOffset=\"0\" a=\"" << inEdgeWidth <<
"\" b=\"" << bCoefficient <<
"\" c=\"" << cCoefficient <<
"\" d=\"" << dCoefficient <<
"\"/>\n";
547 std::string markType =
"broken";
553 }
else if (isOuterEdge && j > 0
568 device <<
" <roadMark sOffset=\"0\" type=\"" << markType <<
"\" weight=\"standard\" color=\"standard\" width=\"0.13\"/>\n";
569 device <<
" <speed sOffset=\"0\" max=\"" << c.
vmax <<
"\"/>\n";
570 device <<
" </lane>\n";
572 junctionDevice <<
" <laneLink from=\"" << fromIndex <<
"\" to=\"" << xJ <<
"\"/>\n";
575 device <<
" </" << side <<
">\n";
579 device <<
" </laneSection>\n";
580 device <<
" </lanes>\n";
581 device <<
" <objects/>\n";
583 device <<
" <signals/>\n";
585 junctionDevice <<
" </connection>\n";
593 for (
int j = 0; j < (int)shape.size() - 1; ++j) {
603 device.
writeAttr(
"length", length < 1e-8 ? 1e-8 : length);
606 elevationDevice <<
" <elevation s=\"" << offset <<
"\" a=\"" << p.
z() <<
"\" b=\"" << (p2.
z() - p.
z()) /
MAX2(POSITION_EPS, length) <<
"\" c=\"0\" d=\"0\"/>\n";
615 device <<
" <center>\n";
616 device <<
" <lane id=\"0\" type=\"none\" level=\"true\">\n";
617 device <<
" <link/>\n";
618 device <<
" <roadMark sOffset=\"0\" type=\"" << mark <<
"\" weight=\"standard\" color=\"standard\" width=\"" << markWidth <<
"\"/>\n";
619 device <<
" </lane>\n";
620 device <<
" </center>\n";
627 return map.
get(origID);
629 map.
insert(origID, lastID++);
636 switch (permissions) {
656 if (permissions ==
SVCAll) {
672 if (laneIndex == -1) {
701 assert(init.size() == 3 || init.size() == 4);
704 length =
MAX2(POSITION_EPS, length);
712 init.
add(-p.
x(), -p.
y(), -p.
z());
716 double aU, bU, cU, dU;
717 double aV, bV, cV, dV;
718 double aZ, bZ, cZ, dZ;
721 if (init.size() == 3) {
724 bU = 2 * init[1].x() - 2 * init[0].x();
725 cU = init[0].x() - 2 * init[1].x() + init[2].x();
729 bV = 2 * init[1].y() - 2 * init[0].y();
730 cV = init[0].y() - 2 * init[1].y() + init[2].y();
735 bZ = (2 * initZ[1].z() - 2 * initZ[0].z()) / length;
736 cZ = (initZ[0].z() - 2 * initZ[1].z() + initZ[2].z()) / (length * length);
742 bU = 3 * init[1].x() - 3 * init[0].x();
743 cU = 3 * init[0].x() - 6 * init[1].x() + 3 * init[2].x();
744 dU = -init[0].x() + 3 * init[1].x() - 3 * init[2].x() + init[3].x();
747 bV = 3 * init[1].y() - 3 * init[0].y();
748 cV = 3 * init[0].y() - 6 * init[1].y() + 3 * init[2].y();
749 dV = -init[0].y() + 3 * init[1].y() - 3 * init[2].y() + init[3].y();
753 bZ = (3 * initZ[1].z() - 3 * initZ[0].z()) / length;
754 cZ = (3 * initZ[0].z() - 6 * initZ[1].z() + 3 * initZ[2].z()) / (length * length);
755 dZ = (-initZ[0].z() + 3 * initZ[1].z() - 3 * initZ[2].z() + initZ[3].z()) / (length * length * length);
774 device.
writeAttr(
"pRange",
"normalized");
779 elevationDevice.
openTag(
"elevation");
787 return offset + length;
793#ifdef DEBUG_SMOOTH_GEOM
795 std::cout <<
"writeGeomSmooth\n n=" << shape.size() <<
" shape=" <<
toString(shape) <<
"\n";
799 const double longThresh = speed;
800 const double curveCutout = longThresh / 2;
802 assert(longThresh >= 2 * curveCutout);
803 assert(shape.size() > 2);
807 double maxAngleDiff = 0;
809 for (
int j = 1; j < (int)shape.size() - 1; ++j) {
817 maxAngleDiff =
MAX2(maxAngleDiff, dAngle);
818#ifdef DEBUG_SMOOTH_GEOM
820 std::cout <<
" j=" << j <<
" dAngle=" <<
RAD2DEG(dAngle) <<
" length1=" << length1 <<
" length2=" << length2 <<
"\n";
823 if (dAngle > straightThresh
824 && (length1 > longThresh || j == 1)
825 && (length2 > longThresh || j == (
int)shape.size() - 2)) {
833 const int numPoints = (int)shape2.size();
834#ifdef DEBUG_SMOOTH_GEOM
836 std::cout <<
" n=" << numPoints <<
" shape2=" <<
toString(shape2) <<
"\n";
840 if (maxAngleDiff < straightThresh) {
842#ifdef DEBUG_SMOOTH_GEOM
844 std::cout <<
" special case: all lines. maxAngleDiff=" << maxAngleDiff <<
"\n";
852 for (
int j = 0; j < numPoints - 1; ++j) {
858 const double lineLength = line.
length2D();
859 if (lineLength >= longThresh) {
861#ifdef DEBUG_SMOOTH_GEOM
863 std::cout <<
" writeLine=" <<
toString(line) <<
"\n";
870 if (j == 0 || j == numPoints - 2) {
873 begShape.
add(p0 - begShape.back());
874 }
else if (j == 1 || p0.
distanceTo2D(shape2[j - 1]) > longThresh) {
876 begShape.push_back(shape2[j - 1]);
877 begShape.push_back(p0);
880 begShape.push_back(shape2[j - 1]);
881 begShape.push_back(p1);
882 begShape.
add(p0 - begShape.back());
885 if (j == 0 || j == numPoints - 2) {
888 endShape.
add(p1 - endShape.front());
889 }
else if (j == numPoints - 3 || p1.
distanceTo2D(shape2[j + 2]) > longThresh) {
891 endShape.push_back(p1);
892 endShape.push_back(shape2[j + 2]);
895 endShape.push_back(p0);
896 endShape.push_back(shape2[j + 2]);
897 endShape.
add(p1 - endShape.front());
899 const double extrapolateLength =
MIN2((
double)25, lineLength / 4);
901 if (init.size() == 0) {
904#ifdef DEBUG_SMOOTH_GEOM
906 std::cout <<
" writeLine lineLength=" << lineLength <<
" begShape" << j <<
"=" <<
toString(begShape) <<
" endShape" << j <<
"=" <<
toString(endShape) <<
" init" << j <<
"=" <<
toString(init) <<
"\n";
912 offset =
writeGeomPP3(device, elevationDevice, init, curveLength, offset);
913#ifdef DEBUG_SMOOTH_GEOM
915 std::cout <<
" writeCurve lineLength=" << lineLength <<
" curveLength=" << curveLength <<
" begShape" << j <<
"=" <<
toString(begShape) <<
" endShape" << j <<
"=" <<
toString(endShape) <<
" init" << j <<
"=" <<
toString(init) <<
"\n";
930 double z = shape.size() == 0 ? 0 : shape[0].z();
931 for (
int i = 1; i < (int)shape.size(); ++i) {
932 if (fabs(shape[i].z() - z) > NUMERICAL_EPS) {
937 device <<
" <elevationProfile>\n";
939 device <<
" <elevation s=\"0\" a=\"" << z <<
"\" b=\"0\" c=\"0\" d=\"0\"/>\n";
943 device <<
" </elevationProfile>\n";
953 assert(shape0.size() >= 2);
957 stopLine.push_back(to);
960 for (
int lane = 1; lane < e->
getNumLanes(); ++lane) {
962 if (dist > NUMERICAL_EPS) {
979 if (poi ==
nullptr) {
990 if (crossings.size() > 0) {
993 for (
size_t ic = 0; ic < crossings.size(); ic++) {
1005std::vector<NWWriter_OpenDrive::TrafficSign>
1007 std::vector<TrafficSign> result;
1009 if (trafficSign ==
"maxspeed" && poi->
hasParameter(
"maxspeed")) {
1011 }
else if (trafficSign ==
"stop") {
1012 result.push_back(
TrafficSign{
"OpenDrive", trafficSign,
"",
"" });
1013 }
else if (trafficSign ==
"give_way") {
1014 result.push_back(
TrafficSign{
"OpenDrive", trafficSign,
"",
"" });
1015 }
else if (trafficSign ==
"hazard" && poi->
hasParameter(
"hazard")) {
1018 if (trafficSign.find_first_of(
",;") != std::string::npos) {
1019 std::string::size_type colon = trafficSign.find(
':');
1020 const std::string country = trafficSign.substr(0, colon);
1021 const std::string remaining = trafficSign.substr(colon + 1);
1023 std::vector<std::string> tokens;
1024 std::string::size_type lastPos = 0;
1025 std::string::size_type pos = remaining.find_first_of(
",;");
1026 while (pos != std::string::npos) {
1028 tokens.push_back(country +
":" + remaining.substr(lastPos, pos - lastPos));
1030 pos = remaining.find_first_of(
",;", lastPos);
1032 tokens.push_back(country +
":" + remaining.substr(lastPos));
1034 for (std::string token : tokens) {
1059 std::regex re(
"([A-Z]{2}):([0-9.]{1,6}|[A-Z]{1}[0-9.]{2,6})(?:\\[(.*)\\])?(?:-(.*))?");
1061 std::regex_match(trafficSign, match, re);
1062 if (match.size() == 5) {
1064 if (match[3].matched) {
1065 value = match[3].str();
1066 }
else if (match[4].matched) {
1067 value = match[4].str();
1069 return TrafficSign{ match[1], match[2],
"", value};
1071 return TrafficSign{
"OpenDrive", trafficSign,
"",
""};
1085 std::map<std::string, bool> toWrite;
1087 if (c.getFrom() == e) {
1088 const std::string
id = tl->
getID() +
"_" +
toString(c.getTLIndex());
1089 if (toWrite.count(
id) == 0) {
1090 toWrite[id] = signalLanes.count(
id) == 0;
1092 signalLanes[id].first.insert(c.getFromLane());
1096 for (
auto item : toWrite) {
1097 const std::string
id = item.first;
1098 const bool isNew = item.second;
1099 const std::set<LinkDirection>& dirs = signalLanes[id].second;
1103 const std::string tag = isNew ?
"signal" :
"signalReference";
1104 int firstLane = *signalLanes[id].first.begin();
1106 for (
int i = firstLane + 1; i < e->
getNumLanes(); i++) {
1118 if (l && !s && !r) {
1121 }
else if (!l && !s && r) {
1124 }
else if (!l && s && !r) {
1127 }
else if (l && s && !r) {
1130 }
else if (!l && s && r) {
1136 device.
writeAttr(
"country",
"OpenDRIVE");
1142 for (
int lane : signalLanes[id].first) {
1154 if (poi !=
nullptr) {
1156 std::string traffic_sign_type = poi->
getParameter(
"traffic_sign");
1158 std::vector<TrafficSign> trafficSigns =
parseTrafficSign(traffic_sign_type, poi);
1162 double calculatedZOffset = 3.0;
1163 for (
auto it = trafficSigns.rbegin(); it != trafficSigns.rend(); ++it) {
1171 device.
writeAttr(
"zOffset", calculatedZOffset);
1179 calculatedZOffset += 0.78;
1210 ? numLanes - sumoIndex
1212 : sumoIndex - numLanes);
1226 std::set<std::string> assigned;
1227 for (
auto it = ec.
begin(); it != ec.
end(); ++it) {
1231 assigned.insert(
id);
1237 for (
auto it = ec.
begin(); it != ec.
end(); ++it) {
1238 NBEdge* edge = it->second;
1240 bound.
grow(maxDist);
1241 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
1242 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
1243 r.
Insert(min, max, edge);
1249 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
1250 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
1251 std::set<const Named*> edges;
1253 r.
Search(min, max, visitor);
1254 std::vector<std::pair<double, std::string> > nearby;
1255 for (
const Named* namedEdge : edges) {
1258 if (distance <= maxDist) {
1260 nearby.push_back(std::make_pair(distance, e->
getID()));
1264 if (nearby.size() > 0) {
1265 std::sort(nearby.begin(), nearby.end());
1268 if (objects !=
"") {
1271 objects += p->
getID();
1278 float min[2] = {
static_cast<float>(p->
x()),
static_cast<float>(p->
y()) };
1279 float max[2] = {
static_cast<float>(p->
x()),
static_cast<float>(p->
y()) };
1280 std::set<const Named*> edges;
1282 r.
Search(min, max, visitor);
1283 std::vector<std::pair<double, std::string> > nearby;
1284 for (
const Named* namedEdge : edges) {
1289 nearby.push_back(std::make_pair(distance, e->
getID()));
1295 if (nearby.size() > 0) {
1296 std::sort(nearby.begin(), nearby.end());
1299 if (objects !=
"") {
1302 objects += p->
getID();
1379 double hdg = -edgeAngle;
1406 device.
writeAttr(
"fillType",
"concrete");
1412 if (hdg != -edgeAngle) {
1417 device.
openTag(
"cornerLocal");
#define WRITE_WARNINGF(...)
const SVCPermissions SVCAll
all VClasses are allowed
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permissions is a railway edge.
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SVC_RAIL
vehicle is a not electrified rail
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_RAIL_FAST
vehicle that is allowed to drive on high-speed rail tracks
@ SVC_RAIL_ELECTRIC
rail vehicle that requires electrified tracks
@ SVC_RAIL_URBAN
vehicle is a city rail
@ SVC_TRAM
vehicle is a light rail
@ SVC_PEDESTRIAN
pedestrian
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
@ PARTLEFT
The link is a partial left direction.
@ RIGHT
The link is a (hard) right direction.
@ LEFT
The link is a (hard) left direction.
@ STRAIGHT
The link is a straight direction.
@ PARTRIGHT
The link is a partial right direction.
int gPrecision
the precision for floating point outputs
#define UNUSED_PARAMETER(x)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static methods for processing the coordinates conversion for the current net
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
const std::string & getProjString() const
Returns the original projection definition.
const Position getOffsetBase() const
Returns the network base.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
const Boundary & getConvBoundary() const
Returns the converted boundary.
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
Storage for edges, including some functionality operating on multiple edges.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
The representation of a single edge during network building.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
const std::vector< Connection > & getConnections() const
Returns the connections.
double getLaneWidth() const
Returns the default width of lanes of this edge.
NBNode * getToNode() const
Returns the destination node of the edge.
Lane & getLaneStruct(int lane)
const PositionVector & getGeometry() const
Returns the geometry of the edge.
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
double getSpeed() const
Returns the speed allowed on this edge.
const std::string & getID() const
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
int getNumLanes() const
Returns the number of lanes.
std::string getLaneID(int lane) const
get lane ID
const std::string & getStreetName() const
Returns the street name of this edge.
NBNode * getFromNode() const
Returns the origin node of the edge.
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
EdgeVector getIncomingEdges() const
Returns the list of incoming edges unsorted.
Instance responsible for building networks.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
ShapeContainer & getShapeCont()
NBEdgeCont & getEdgeCont()
Container for nodes during the netbuilding process.
int size() const
Returns the number of nodes stored in this container.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
Represents a single node (junction) during network building.
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing, bool leftHand=false) const
Returns the representation of the described stream's direction.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
int numNormalConnections() const
return the number of lane-to-lane connections at this junction (excluding crossings)
std::vector< Crossing * > getCrossings() const
return this junctions pedestrian crossings
bool geometryLike() const
whether this is structurally similar to a geometry node
bool isTLControlled() const
Returns whether this node is controlled by any tls.
static PositionVector bezierControlPoints(const PositionVector &begShape, const PositionVector &endShape, bool isTurnaround, double extrapolateBeg, double extrapolateEnd, bool &ok, NBNode *recordError=0, double straightThresh=DEG2RAD(5), int shapeFlag=0)
get bezier control points
The base class for traffic light logic definitions.
const NBConnectionVector & getControlledLinks() const
returns the controlled links (depends on previous call to collectLinks)
static PositionVector getInnerLaneBorder(const NBEdge *edge, int laneIndex=-1, double widthOffset=0)
get the lane border that is closer to the reference line (center line of the edge)
static void writeRoadObjectPOI(OutputDevice &device, const NBEdge *e, const PositionVector &roadShape, const PointOfInterest *poi)
static void mapmatchRoadObjects(const ShapeContainer &shc, const NBEdgeCont &ec)
map pois and polygons to the closes edge
static void addPedestrianConnection(const NBEdge *inEdge, const NBEdge *outEdge, std::vector< NBEdge::Connection > ¶llel)
static void writeNormalEdge(OutputDevice &device, const NBEdge *e, int edgeID, int fromNodeID, int toNodeID, const bool origNames, const double straightThresh, const ShapeContainer &shc, SignalLanes &signalLanes, const std::vector< std::string > &crossings)
write normal edge to device
static void checkLaneGeometries(const NBEdge *e)
check if the lane geometries are compatible with OpenDRIVE assumptions (colinear stop line)
static std::vector< TrafficSign > parseTrafficSign(const std::string &trafficSign, PointOfInterest *poi)
std::map< std::string, std::pair< std::set< int >, std::set< LinkDirection > > > SignalLanes
signalID -> (lanes, dirs)
static double getRoadSideOffset(const NBEdge *e)
static void writeEmptyCenterLane(OutputDevice &device, const std::string &mark, double markWidth)
static void writeSignals(OutputDevice &device, const NBEdge *e, double length, SignalLanes &signalLanes, const ShapeContainer &shc)
write signal record for traffic light
static void writeRoadObjects(OutputDevice &device, const NBEdge *e, const ShapeContainer &shc, const std::vector< std::string > &crossings)
write road objects referenced as edge parameters
static bool lefthand
whether a lefthand network is being written
static void writeRoadObjectPoly(OutputDevice &device, const NBEdge *e, const PositionVector &roadShape, const SUMOPolygon *p)
static void writeElevationProfile(const PositionVector &shape, OutputDevice &device, const OutputDevice_String &elevationDevice)
static std::string getDividerType(const NBEdge *e)
retrieve divider type
static std::string getLaneType(SVCPermissions permissions)
static bool writeGeomSmooth(const PositionVector &shape, double speed, OutputDevice &device, OutputDevice &elevationDevice, double straightThresh, double &length)
static int s2x(int sumoIndex, int numLanes)
convert sumo lane index to xodr lane index
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into a openDRIVE-file.
static int getID(const std::string &origID, StringBijection< int > &map, int &lastID)
static double writeGeomPP3(OutputDevice &device, OutputDevice &elevationDevice, PositionVector init, double length, double offset=0)
write geometry as a single bezier curve (paramPoly3)
static int writeInternalEdge(OutputDevice &device, OutputDevice &junctionDevice, const NBEdge *inEdge, int nodeID, int edgeID, int inEdgeID, int outEdgeID, int connectionID, const std::vector< NBEdge::Connection > ¶llel, const bool isOuterEdge, const double straightThresh, const std::string ¢erMark, SignalLanes &signalLanes)
write internal edge to device, return next connectionID
static TrafficSign parseTrafficSignId(const std::string &trafficSign)
static PositionVector getOuterLaneBorder(const NBEdge *edge, int laneIndex=-1)
get the lane border that is further away from the reference line (center line of the edge)
static double writeGeomLines(const PositionVector &shape, OutputDevice &device, OutputDevice &elevationDevice, double offset=0)
write geometry as sequence of lines (sumo style)
Allows to store the object; used as context while traveling the rtree in TraCI.
Base class for objects which have an id.
const std::string & getID() const
Returns the id.
T get(const std::string &id) const
Retrieves an item.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
int size() const
Returns the number of stored items within the container.
A RT-tree for efficient storing of SUMO's Named objects.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
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.
An output device that encapsulates an ofstream.
std::string getString() const
Returns the current content as a string.
Static storage of an output device and its base (abstract) implementation.
void lf()
writes a line feed if applicable
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
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 hasParameter(const std::string &key) const
Returns whether the parameter is set.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
A point in 2D or 3D with translation and scaling methods.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double x() const
Returns the x-position.
double z() const
Returns the z-position.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
double y() const
Returns the y-position.
double length2D() const
Returns the length.
void append(const PositionVector &v, double sameThreshold=2.0)
void rotate2D(double angle)
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
void add(double xoff, double yoff, double zoff)
static Position sideOffset(const Position &beg, const Position &end, const double amount)
get a side position of position vector using a offset
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector)
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
std::vector< double > distances(const PositionVector &s, bool perpendicular=false) const
distances of all my points to s and all of s points to myself
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
PositionVector getSubpart2D(double beginOffset, double endOffset) const
get subpart of a position vector in two dimensions (Z is ignored)
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
double angleAt2D(int pos) const
get angle in certain position of position vector (in radians between -M_PI and M_PI)
PositionVector bezier(int numPoints)
return a bezier interpolation
int insertAtClosest(const Position &p, bool interpolateZ)
inserts p between the two closest positions
bool isClosed() const
check if PositionVector is closed
int removeClosest(const Position &p)
removes the point closest to p and return the removal index
PositionVector reverse() const
reverse position vector
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
void sub(const Position &offset)
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
const PositionVector & getShape() const
Returns the shape of the polygon.
Storage for geometrical objects.
const Polygons & getPolygons() const
Returns all polygons.
virtual bool addPolygon(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, const PositionVector &shape, bool geo, bool fill, double lineWidth, bool ignorePruning=false, const std::string &name=Shape::DEFAULT_NAME)
Builds a polygon using the given values and adds it to the container.
const POIs & getPOIs() const
Returns all pois.
static const bool DEFAULT_RELATIVEPATH
static const std::string DEFAULT_IMG_FILE
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
static const double DEFAULT_ANGLE
double getShapeLayer() const
Returns the layer of the Shape.
bool hasString(const std::string &str) const
T get(const std::string &str) const
void insert(const std::string str, const T key, bool checkDuplicates=true)
std::vector< std::string > getVector()
return vector of strings
static double toDoubleSecure(const std::string &sData, const double def)
converts a string into the integer value described by it
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
static T minValue(const std::vector< T > &v)
A structure which describes a connection between edges or lanes.
int fromLane
The lane the connections starts at.
int toLane
The lane the connections yields in.
NBEdge * toEdge
The edge the connections yields in.
double vmax
maximum velocity
std::string id
id of Connection
std::string type
the type of this lane