Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netbuild/NBHelpers.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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 NBHelpers.h
15
/// @author Daniel Krajzewicz
16
/// @author Sascha Krieg
17
/// @author Michael Behrisch
18
/// @author Jakob Erdmann
19
/// @date Tue, 20 Nov 2001
20
///
21
// Some mathematical helper methods
22
/****************************************************************************/
23
#pragma once
24
#include <config.h>
25
26
#include <string>
27
#include <set>
28
29
30
// ===========================================================================
31
// class declarations
32
// ===========================================================================
33
class NBNode;
34
class Position;
35
36
37
// ===========================================================================
38
// class definitions
39
// ===========================================================================
40
/**
41
* @class NBHelpers
42
* Some mathmatical methods for the computation of angles
43
*/
44
class NBHelpers {
45
public:
46
/// @brief computes the relative angle between the two angles
47
static double relAngle(double angle1, double angle2);
48
49
/// @brief ensure that reverse relAngles (>=179.999) always count as turnarounds (-180)
50
static double normRelAngle(double angle1, double angle2);
51
52
/// @brief converts the numerical id to its "normal" string representation
53
static std::string normalIDRepresentation(const std::string& id);
54
55
/// @brief returns the distance between both nodes
56
static double distance(NBNode* node1, NBNode* node2);
57
58
/// @brief Add edge ids defined in file (either ID or edge:ID per line) into the given set
59
static void loadEdgesFromFile(const std::string& file, std::set<std::string>& into);
60
61
/// @brief Add prefixed ids defined in file
62
static void loadPrefixedIDsFomFile(const std::string& file, const std::string prefix, std::set<std::string>& into);
63
64
/** @brief parses edge-id and index from lane-id
65
* @param[in] lane_id The lane-id
66
* @param[out] edge_id ID of this lane's edge
67
* @param[out] index Index of this lane
68
*/
69
static void interpretLaneID(const std::string& lane_id, std::string& edge_id, int& index);
70
};
71
72