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-2020 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 // ===========================================================================
31 class NBNetBuilder;
32 class NBEdge;
33 class OptionsCont;
34 class PositionVector;
35 class OutputDevice;
37 class ShapeContainer;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
49 public:
55  static void writeNetwork(const OptionsCont& oc, NBNetBuilder& nb);
56 
57 protected:
59  static void writeNormalEdge(OutputDevice& device, const NBEdge* e,
60  int edgeID, int fromNodeID, int toNodeID,
61  const bool origNames,
62  const double straightThresh,
63  const ShapeContainer& shc);
64 
66  static int writeInternalEdge(OutputDevice& device, OutputDevice& junctionDevice,
67  const NBEdge* inEdge, int nodeID,
68  int edgeID, int inEdgeID, int outEdgeID,
69  int connectionID,
70  const std::vector<NBEdge::Connection>& parallel,
71  const bool isOuterEdge,
72  const double straightThresh,
73  const std::string& centerMark);
74 
75  static void addPedestrianConnection(const NBEdge* inEdge, const NBEdge* outEdge, std::vector<NBEdge::Connection>& parallel);
76 
78  static double writeGeomLines(const PositionVector& shape, OutputDevice& device, OutputDevice& elevationDevice, double offset = 0);
79 
80  /* @brief write geometry as sequence of lines and bezier curves
81  *
82  * @param[in] straightThresh angular changes below threshold are considered to be straight and no curve will be fitted between the segments
83  * @param[out] length Return the total length of the reference line
84  */
85  static bool writeGeomSmooth(const PositionVector& shape, double speed, OutputDevice& device, OutputDevice& elevationDevice, double straightThresh, double& length);
86 
88  static double writeGeomPP3(OutputDevice& device,
89  OutputDevice& elevationDevice,
90  PositionVector init,
91  double length,
92  double offset = 0);
93 
94  static void writeElevationProfile(const PositionVector& shape, OutputDevice& device, const OutputDevice_String& elevationDevice);
95 
96  static void writeEmptyCenterLane(OutputDevice& device, const std::string& mark, double markWidth);
97  static int getID(const std::string& origID, StringBijection<int>& map, int& lastID);
98 
99  static std::string getLaneType(SVCPermissions permissions);
100 
102  static PositionVector getLeftLaneBorder(const NBEdge* edge, int laneIndex = -1, double widthOffset = 0);
103  static PositionVector getRightLaneBorder(const NBEdge* edge, int laneIndex = -1);
104 
106  static void checkLaneGeometries(const NBEdge* e);
107 
109  static void writeRoadObjects(OutputDevice& device, const NBEdge* e, const ShapeContainer& shc);
110 };
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:91
Instance responsible for building networks.
Definition: NBNetBuilder.h:107
Exporter writing networks using the openDRIVE format.
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)
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)
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 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)
write internal edge to device, return next connectionID
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 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:60
A list of positions.
Storage for geometrical objects.