1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
10 /// @file    NWWriter_OpenDrive.h
11 /// @author  Daniel Krajzewicz
12 /// @date    Tue, 04.05.2011
13 /// @version $Id$
14 ///
15 // Exporter writing networks using the openDRIVE format
16 /****************************************************************************/
17 #ifndef NWWriter_OpenDrive_h
18 #define NWWriter_OpenDrive_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <utils/common/StringBijection.h>
27 #include <utils/common/SUMOVehicleClass.h>
28 #include <netbuild/NBEdge.h>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class NBNetBuilder;
35 class NBEdge;
36 class OptionsCont;
37 class PositionVector;
38 class OutputDevice;
39 class OutputDevice_String;
40 class ShapeContainer;
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
46 /**
47  * @class NWWriter_OpenDrive
48  * @brief Exporter writing networks using the openDRIVE format
49  *
50  */
51 class NWWriter_OpenDrive {
52 public:
53     /** @brief Writes the network into a openDRIVE-file
54      *
55      * @param[in] oc The options to use
56      * @param[in] nb The network builder to fill
57      */
58     static void writeNetwork(const OptionsCont& oc, NBNetBuilder& nb);
59 
60 protected:
61     /// @brief write normal edge to device
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 
68     /// @brief write internal edge to device, return next connectionID
69     static int writeInternalEdge(OutputDevice& device, OutputDevice& junctionDevice,
70                                  const NBEdge* inEdge, int nodeID,
71                                  int edgeID, int inEdgeID, int outEdgeID,
72                                  int connectionID,
73                                  const std::vector<NBEdge::Connection>& parallel,
74                                  const bool isOuterEdge,
75                                  const double straightThresh,
76                                  const std::string& centerMark);
77 
78     static void addPedestrianConnection(const NBEdge* inEdge, const NBEdge* outEdge, std::vector<NBEdge::Connection>& parallel);
79 
80     /// @brief write geometry as sequence of lines (sumo style)
81     static double writeGeomLines(const PositionVector& shape, OutputDevice& device, OutputDevice& elevationDevice, double offset = 0);
82 
83     /* @brief write geometry as sequence of lines and bezier curves
84      *
85      * @param[in] straightThresh angular changes below threshold are considered to be straight and no curve will be fitted between the segments
86      * @param[out] length Return the total length of the reference line
87      */
88     static bool writeGeomSmooth(const PositionVector& shape, double speed, OutputDevice& device, OutputDevice& elevationDevice, double straightThresh, double& length);
89 
90     /// @brief write geometry as a single bezier curve (paramPoly3)
91     static double writeGeomPP3(OutputDevice& device,
92                                OutputDevice& elevationDevice,
93                                PositionVector init,
94                                double length,
95                                double offset = 0);
96 
97     static void writeElevationProfile(const PositionVector& shape, OutputDevice& device, const OutputDevice_String& elevationDevice);
98 
99     static void writeEmptyCenterLane(OutputDevice& device, const std::string& mark, double markWidth);
100     static int getID(const std::string& origID, StringBijection<int>& map, int& lastID);
101 
102     static std::string getLaneType(SVCPermissions permissions);
103 
104     /// @brief get the left border of the given lane (the leftmost one by default)
105     static PositionVector getLeftLaneBorder(const NBEdge* edge, int laneIndex = -1, double widthOffset = 0);
106     static PositionVector getRightLaneBorder(const NBEdge* edge, int laneIndex = -1);
107 
108     /// @brief check if the lane geometries are compatible with OpenDRIVE assumptions (colinear stop line)
109     static void checkLaneGeometries(const NBEdge* e);
110 
111     /// @brief write road objects referenced as edge parameters
112     static void writeRoadObjects(OutputDevice& device, const NBEdge* e, const ShapeContainer& shc);
113 };
114 
115 
116 #endif
117 
118 /****************************************************************************/
119 
120