Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2012-2026 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 : /****************************************************************************/
14 : /// @file NWWriter_DlrNavteq.h
15 : /// @author Jakob Erdmann
16 : /// @author Michael Behrisch
17 : /// @date 26.10.2012
18 : ///
19 : // Exporter writing networks using DlrNavteq (Elmar) format
20 : /****************************************************************************/
21 : #pragma once
22 : #include <config.h>
23 :
24 : #include <string>
25 : #include <map>
26 : #include <utils/xml/SUMOSAXHandler.h>
27 : #include <utils/common/UtilExceptions.h>
28 :
29 :
30 : // ===========================================================================
31 : // class declarations
32 : // ===========================================================================
33 : class NBEdge;
34 : class NBEdgeCont;
35 : class NBNetBuilder;
36 : class NBNode;
37 : class NBNodeCont;
38 : class NBTrafficLightLogicCont;
39 : class NBTypeCont;
40 : class OptionsCont;
41 :
42 :
43 : // ===========================================================================
44 : // class definitions
45 : // ===========================================================================
46 : /**
47 : * @class NWWriter_DlrNavteq
48 : * @brief Exporter writing networks using XML (native input) format
49 : *
50 : */
51 : class NWWriter_DlrNavteq {
52 : public:
53 : /** @brief Writes the network into XML-files (nodes, edges, connections,
54 : * traffic lights)
55 : * @param[in] oc The options to use
56 : * @param[in] nb The network builder from which to read data
57 : */
58 : static void writeNetwork(const OptionsCont& oc, NBNetBuilder& nb);
59 :
60 : /// @brief get the navteq road class
61 : static int getRoadClass(const NBEdge* const edge);
62 :
63 : /// @brief get the navteq brunnel type
64 : static int getBrunnelType(const NBEdge* const edge);
65 :
66 : /// @brief get the form of way
67 : static int getFormOfWay(const NBEdge* const edge);
68 :
69 : /// @brief extra attributes into plain output
70 : static void writeEdgeAttrs(OutputDevice& device, const NBEdge* edge);
71 : static void writeConnectionAttrs(OutputDevice& device, const NBEdge::Connection& c);
72 :
73 : private:
74 : /** @brief Writes the nodes_unsplitted file
75 : * @param[in] oc The options to use
76 : * @param[in] nc The node-container from which to read data
77 : * @param[in] ec The edge-container from which to read data
78 : * @param[out] internalNodes The internal node ids, generated for edges with complex geometry
79 : */
80 : static void writeNodesUnsplitted(const OptionsCont& oc, const NBNodeCont& nc, const NBEdgeCont& ec, std::map<const NBEdge*, std::string>& internalNodes);
81 :
82 : /** @brief Writes the links_unsplitted file
83 : * @param[in] oc The options to use
84 : * @param[in] ec The edge-container from which to read data
85 : * @param[int] internalNodes The internal node ids, generated for edges with complex geometry
86 : */
87 : static void writeLinksUnsplitted(const OptionsCont& oc, const NBEdgeCont& ec, const std::map<const NBEdge*, std::string>& internalNodes);
88 :
89 : /** @brief Writes the traffic_signals file
90 : * @param[in] oc The options to use
91 : * @param[in] nc The node-container from which to read data
92 : */
93 : static void writeTrafficSignals(const OptionsCont& oc, NBNodeCont& nc);
94 :
95 :
96 : /** @brief Writes the prohibited_manoeuvres file
97 : * @param[in] oc The options to use
98 : * @param[in] nc The node-container from which to read data
99 : */
100 : static void writeProhibitedManoeuvres(const OptionsCont& oc, const NBNodeCont& nc, const NBEdgeCont& ec);
101 :
102 : /** @brief Writes the connected_lanes file
103 : * @param[in] oc The options to use
104 : * @param[in] nc The node-container from which to read data
105 : */
106 : static void writeConnectedLanes(const OptionsCont& oc, NBNodeCont& nc);
107 :
108 : /// @brief write header comments (input parameters, date, etc...)
109 : static void writeHeader(OutputDevice& device, const OptionsCont& oc);
110 :
111 : /// @brief build the ascii-bit-vector for column vehicle_type
112 : static std::string getAllowedTypes(SVCPermissions permissions);
113 :
114 : /// @brief get the navteq speed class based on the speed in km/h
115 : static int getSpeedCategory(int kph);
116 :
117 : /// @brief get the SPEED_LIMIT as defined by elmar (upper bound of speed category)
118 : static int getSpeedCategoryUpperBound(int kph);
119 :
120 : /// @brief get the lane number encoding
121 : static int getNavteqLaneCode(const int numLanes);
122 :
123 : /// @brief get the length of the edge when measured up to the junction center
124 : static double getGraphLength(const NBEdge* const edge);
125 :
126 : static std::string getSinglePostalCode(const std::string& zipCode, const std::string edgeID);
127 :
128 : /// @brief magic value for undefined stuff
129 : static const std::string UNDEFINED;
130 :
131 : /// @brief get edge speed rounded to kmh
132 : static inline int speedInKph(double metersPerSecond) {
133 1245 : return (int)std::floor(metersPerSecond * 3.6 + 0.5);
134 : }
135 :
136 : /// @brief get the maximum width of all lanes
137 : static double getMaxLaneWidth(const NBEdge* const edge);
138 : };
|