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    NBHelpers.h
11 /// @author  Daniel Krajzewicz
12 /// @author  Sascha Krieg
13 /// @author  Michael Behrisch
14 /// @author  Jakob Erdmann
15 /// @date    Tue, 20 Nov 2001
16 /// @version $Id$
17 ///
18 // Some mathematical helper methods
19 /****************************************************************************/
20 #ifndef NBHelpers_h
21 #define NBHelpers_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <set>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class NBNode;
37 class Position;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
43 /**
44  * @class NBHelpers
45  * Some mathmatical methods for the computation of angles
46  */
47 class NBHelpers {
48 public:
49     /// @brief computes the relative angle between the two angles
50     static double relAngle(double angle1, double angle2);
51 
52     /// @brief ensure that reverse relAngles (>=179.999) always count as turnarounds (-180)
53     static double normRelAngle(double angle1, double angle2);
54 
55     /// @brief converts the numerical id to its "normal" string representation
56     static std::string normalIDRepresentation(const std::string& id);
57 
58     /// @brief returns the distance between both nodes
59     static double distance(NBNode* node1, NBNode* node2);
60 
61     /// @brief Add edge ids defined in file (either ID or edge:ID per line) into the given set
62     static void loadEdgesFromFile(const std::string& file, std::set<std::string>& into);
63 
64     /// @brief Add prefixed ids defined in file
65     static void loadPrefixedIDsFomFile(const std::string& file, const std::string prefix,  std::set<std::string>& into);
66 
67     /** @brief parses edge-id and index from lane-id
68      * @param[in] lane_id The lane-id
69      * @param[out] edge_id ID of this lane's edge
70      * @param[out] index Index of this lane
71      */
72     static void interpretLaneID(const std::string& lane_id, std::string& edge_id, int& index);
73 };
74 
75 
76 #endif
77 
78 /****************************************************************************/
79 
80