47 #ifdef CHECK_MEMORY_LEAKS 49 #endif // CHECK_MEMORY_LEAKS 51 #define MIN_TURN_DIAMETER 2.0 63 if (!oc.
isSet(
"opendrive-output")) {
66 const bool origNames = oc.
getBool(
"output.original-names");
74 device <<
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
77 std::string dstr(ctime(&now));
82 device.openTag(
"header");
83 device.writeAttr(
"revMajor",
"1");
84 device.writeAttr(
"revMinor",
"3");
85 device.writeAttr(
"name",
"");
86 device.writeAttr(
"version",
"1.00");
87 device.writeAttr(
"date", dstr.substr(0, dstr.length() - 1));
88 device.writeAttr(
"north", b.
ymax());
89 device.writeAttr(
"south", b.
ymin());
90 device.writeAttr(
"east", b.
xmax());
91 device.writeAttr(
"west", b.
xmin());
92 device.writeAttr(
"maxRoad", ec.
size());
93 device.writeAttr(
"maxJunc", nc.
size());
94 device.writeAttr(
"maxPrg", 0);
98 for (std::map<std::string, NBEdge*>::const_iterator i = ec.
begin(); i != ec.
end(); ++i) {
99 const NBEdge* e = (*i).second;
101 device <<
" <link>\n";
102 device <<
" <predecessor elementType=\"junction\" elementId=\"" <<
getID(e->
getFromNode()->
getID(), nodeMap, nodeID) <<
"\"/>\n";
103 device <<
" <successor elementType=\"junction\" elementId=\"" <<
getID(e->
getToNode()->
getID(), nodeMap, nodeID) <<
"\"/>\n";
104 device <<
" </link>\n";
105 device <<
" <type s=\"0\" type=\"town\"/>\n";
107 const std::vector<NBEdge::Lane>& lanes = e->
getLanes();
110 device <<
" <elevationProfile><elevation s=\"0\" a=\"0\" b=\"0\" c=\"0\" d=\"0\"/></elevationProfile>\n";
111 device <<
" <lateralProfile/>\n";
112 device <<
" <lanes>\n";
113 device <<
" <laneSection s=\"0\">\n";
115 device <<
" <right>\n";
118 device <<
" <link/>\n";
126 device <<
" <width sOffset=\"0\" a=\"" << e->
getLaneWidth(j) <<
"\" b=\"0\" c=\"0\" d=\"0\"/>\n";
127 std::string markType =
"broken";
131 device <<
" <roadMark sOffset=\"0\" type=\"" << markType <<
"\" weight=\"standard\" color=\"standard\" width=\"0.13\"/>\n";
132 device <<
" <speed sOffset=\"0\" max=\"" << lanes[j].speed <<
"\"/>\n";
133 device <<
" </lane>\n";
135 device <<
" </right>\n";
136 device <<
" </laneSection>\n";
137 device <<
" </lanes>\n";
138 device <<
" <objects/>\n";
139 device <<
" <signals/>\n";
141 device <<
" <userData sumoId=\"" << e->
getID() <<
"\"/>\n";
143 device <<
" </road>\n";
147 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
150 for (std::vector<NBEdge*>::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
151 const NBEdge* inEdge = *j;
152 const std::vector<NBEdge::Connection>& elv = inEdge->
getConnections();
153 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
181 if (shape.size() > 1) {
191 device <<
" <link>\n";
192 device <<
" <predecessor elementType=\"road\" elementId=\"" <<
getID(inEdge->
getID(), edgeMap, edgeID) <<
"\" contactPoint=\"end\"/>\n";
193 device <<
" <successor elementType=\"road\" elementId=\"" <<
getID(outEdge->
getID(), edgeMap, edgeID) <<
"\" contactPoint=\"start\"/>\n";
194 device <<
" </link>\n";
195 device <<
" <type s=\"0\" type=\"town\"/>\n";
197 device <<
" <elevationProfile><elevation s=\"0\" a=\"0\" b=\"0\" c=\"0\" d=\"0\"/></elevationProfile>\n";
198 device <<
" <lateralProfile/>\n";
199 device <<
" <lanes>\n";
200 device <<
" <laneSection s=\"0\">\n";
202 device <<
" <right>\n";
204 device <<
" <link>\n";
207 device <<
" </link>\n";
208 device <<
" <width sOffset=\"0\" a=\"" << width <<
"\" b=\"0\" c=\"0\" d=\"0\"/>\n";
209 device <<
" <roadMark sOffset=\"0\" type=\"none\" weight=\"standard\" color=\"standard\" width=\"0.13\"/>\n";
210 device <<
" </lane>\n";
211 device <<
" </right>\n";
212 device <<
" </laneSection>\n";
213 device <<
" </lanes>\n";
214 device <<
" <objects/>\n";
215 device <<
" <signals/>\n";
216 device <<
" </road>\n";
222 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
224 device <<
" <junction name=\"" << n->
getID() <<
"\" id=\"" <<
getID(n->
getID(), nodeMap, nodeID) <<
"\">\n";
225 unsigned int index = 0;
227 for (std::vector<NBEdge*>::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
228 const NBEdge* inEdge = *j;
229 const std::vector<NBEdge::Connection>& elv = inEdge->
getConnections();
230 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
236 device <<
" <connection id=\"" 237 << index <<
"\" incomingRoad=\"" <<
getID(inEdge->
getID(), edgeMap, edgeID)
238 <<
"\" connectingRoad=\"" 240 <<
"\" contactPoint=\"start\">\n";
244 device <<
" </connection>\n";
248 device <<
" </junction>\n";
258 device <<
" <planView>\n";
260 for (
unsigned int j = 0; j < shape.size() - 1; ++j) {
264 device << std::setprecision(8);
265 device <<
" <geometry s=\"" << offset <<
"\" x=\"" << p.
x() <<
"\" y=\"" << p.
y() <<
"\" hdg=\"" << hdg <<
"\" length=\"" << length <<
"\"><line/></geometry>\n";
269 device <<
" </planView>\n";
275 device <<
" <center>\n";
276 device <<
" <lane id=\"0\" type=\"none\" level= \"0\">\n";
277 device <<
" <link/>\n";
278 device <<
" <roadMark sOffset=\"0\" type=\"" << mark <<
"\" weight=\"standard\" color=\"standard\" width=\"" << markWidth <<
"\"/>\n";
279 device <<
" <width sOffset=\"0\" a=\"0\" b=\"0\" c=\"0\" d=\"0\"/>\n";
280 device <<
" </lane>\n";
281 device <<
" </center>\n";
288 return map.
get(origID);
290 map.
insert(origID, lastID++);
297 switch (permissions) {
318 if (laneIndex == -1) {
326 for (
int i = leftmost; i > laneIndex; i--) {
static void writePlanView(const PositionVector &shape, OutputDevice &device)
const PositionVector & getLaneShape(unsigned int i) const
Returns the shape of the nth lane.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
A structure which describes a connection between edges or lanes.
int toLane
The lane the connections yields in.
NBEdge * toEdge
The edge the connections yields in.
bool hasString(const std::string &str) const
SUMOReal ymin() const
Returns minimum y-coordinate.
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
static std::string escapeXML(const std::string &orig)
Replaces the standard escapes by their XML entities.
SUMOReal xmin() const
Returns minimum x-coordinate.
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
SUMOReal x() const
Returns the x-position.
SUMOReal xmax() const
Returns maximum x-coordinate.
A class that stores a 2D geometrical boundary.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const std::string & getID() const
Returns the id.
void insert(const std::string str, const T key, bool checkDuplicates=true)
unsigned int size() const
Returns the number of known nodes.
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into a openDRIVE-file.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
std::string getInternalLaneID() const
int fromLane
The lane the connections starts at.
A point in 2D or 3D with translation and scaling methods.
NBEdgeCont & getEdgeCont()
Returns the edge container.
unsigned int getNumLanes() const
Returns the number of lanes.
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
static void writeEmptyCenterLane(OutputDevice &device, const std::string &mark, SUMOReal markWidth)
Storage for edges, including some functionality operating on multiple edges.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
const Boundary & getConvBoundary() const
Returns the converted boundary.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
SUMOReal length() const
Returns the length.
static std::string getLaneType(SVCPermissions permissions)
NBNode * getToNode() const
Returns the destination node of the edge.
SUMOReal angleAt2D(int pos) const
NBNodeCont & getNodeCont()
Returns the node container.
Instance responsible for building networks.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
SUMOReal y() const
Returns the y-position.
A storage for options typed value containers)
static PositionVector getLeftLaneBorder(const NBEdge *edge, int laneIndex=-1)
get the left border of the given lane (the leftmost one by default)
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
#define MIN_TURN_DIAMETER
Represents a single node (junction) during network building.
T get(const std::string &str) const
void move2side(SUMOReal amount)
Static storage of an output device and its base (abstract) implementation.
SUMOReal ymax() const
Returns maximum y-coordinate.
Container for nodes during the netbuilding process.
static int getID(const std::string &origID, StringBijection< int > &map, int &lastID)
const std::string & getStreetName() const
Returns the street name of this edge.
const std::vector< Connection > & getConnections() const
Returns the connections.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
void append(const PositionVector &v, SUMOReal sameThreshold=2.0)
unsigned int size() const
Returns the number of edges.
SUMOReal getLength() const
Returns the computed length of the edge.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
NBNode * getFromNode() const
Returns the origin node of the edge.