Eclipse SUMO - Simulation of Urban MObility
NWWriter_OpenDrive.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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/****************************************************************************/
18// Exporter writing networks using the openDRIVE format
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
25#include <netbuild/NBEdge.h>
26
27
28// ===========================================================================
29// class declarations
30// ===========================================================================
31class NBNetBuilder;
32class NBEdge;
33class OptionsCont;
34class PositionVector;
35class OutputDevice;
37class ShapeContainer;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
49public:
55 static void writeNetwork(const OptionsCont& oc, NBNetBuilder& nb);
56
57protected:
59 typedef std::map<std::string, std::pair<std::set<int>, std::set<LinkDirection> > > SignalLanes;
60
62 static void writeNormalEdge(OutputDevice& device, const NBEdge* e,
63 int edgeID, int fromNodeID, int toNodeID,
64 const bool origNames,
65 const double straightThresh,
66 const ShapeContainer& shc,
67 SignalLanes& signalLanes);
68
70 static int writeInternalEdge(OutputDevice& device, OutputDevice& junctionDevice,
71 const NBEdge* inEdge, int nodeID,
72 int edgeID, int inEdgeID, int outEdgeID,
73 int connectionID,
74 const std::vector<NBEdge::Connection>& parallel,
75 const bool isOuterEdge,
76 const double straightThresh,
77 const std::string& centerMark,
78 SignalLanes& signalLanes);
79
80 static void addPedestrianConnection(const NBEdge* inEdge, const NBEdge* outEdge, std::vector<NBEdge::Connection>& parallel);
81
83 static double writeGeomLines(const PositionVector& shape, OutputDevice& device, OutputDevice& elevationDevice, double offset = 0);
84
85 /* @brief write geometry as sequence of lines and bezier curves
86 *
87 * @param[in] straightThresh angular changes below threshold are considered to be straight and no curve will be fitted between the segments
88 * @param[out] length Return the total length of the reference line
89 */
90 static bool writeGeomSmooth(const PositionVector& shape, double speed, OutputDevice& device, OutputDevice& elevationDevice, double straightThresh, double& length);
91
93 static double writeGeomPP3(OutputDevice& device,
94 OutputDevice& elevationDevice,
95 PositionVector init,
96 double length,
97 double offset = 0);
98
99 static void writeElevationProfile(const PositionVector& shape, OutputDevice& device, const OutputDevice_String& elevationDevice);
100
101 static void writeEmptyCenterLane(OutputDevice& device, const std::string& mark, double markWidth);
102 static int getID(const std::string& origID, StringBijection<int>& map, int& lastID);
103
104 static std::string getLaneType(SVCPermissions permissions);
105
107 static PositionVector getLeftLaneBorder(const NBEdge* edge, int laneIndex = -1, double widthOffset = 0);
108 static PositionVector getRightLaneBorder(const NBEdge* edge, int laneIndex = -1);
109
111 static void checkLaneGeometries(const NBEdge* e);
112
114 static void writeRoadObjects(OutputDevice& device, const NBEdge* e, const ShapeContainer& shc);
115
117 static void writeSignals(OutputDevice& device, const NBEdge* e, double length, SignalLanes& signalLanes);
118};
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
The representation of a single edge during network building.
Definition: NBEdge.h:92
Instance responsible for building networks.
Definition: NBNetBuilder.h:107
Exporter writing networks using the openDRIVE format.
static void writeSignals(OutputDevice &device, const NBEdge *e, double length, SignalLanes &signalLanes)
write signal record for traffic light
static void addPedestrianConnection(const NBEdge *inEdge, const NBEdge *outEdge, std::vector< NBEdge::Connection > &parallel)
static void checkLaneGeometries(const NBEdge *e)
check if the lane geometries are compatible with OpenDRIVE assumptions (colinear stop line)
std::map< std::string, std::pair< std::set< int >, std::set< LinkDirection > > > SignalLanes
signalID -> (lanes, dirs)
static void writeEmptyCenterLane(OutputDevice &device, const std::string &mark, double markWidth)
static void writeElevationProfile(const PositionVector &shape, OutputDevice &device, const OutputDevice_String &elevationDevice)
static PositionVector getRightLaneBorder(const NBEdge *edge, int laneIndex=-1)
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)
write normal edge to device
static std::string getLaneType(SVCPermissions permissions)
static bool writeGeomSmooth(const PositionVector &shape, double speed, OutputDevice &device, OutputDevice &elevationDevice, double straightThresh, double &length)
static void writeRoadObjects(OutputDevice &device, const NBEdge *e, const ShapeContainer &shc)
write road objects referenced as edge parameters
static PositionVector getLeftLaneBorder(const NBEdge *edge, int laneIndex=-1, double widthOffset=0)
get the left border of the given lane (the leftmost one by default)
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 > &parallel, const bool isOuterEdge, const double straightThresh, const std::string &centerMark, SignalLanes &signalLanes)
write internal edge to device, return next connectionID
static double writeGeomLines(const PositionVector &shape, OutputDevice &device, OutputDevice &elevationDevice, double offset=0)
write geometry as sequence of lines (sumo style)
A storage for options typed value containers)
Definition: OptionsCont.h:89
An output device that encapsulates an ofstream.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
A list of positions.
Storage for geometrical objects.