Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/common/LinearApproxHelpers.h
169678 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 LinearApproxHelpers.h
15
/// @author Mirko Barthauer
16
/// @date 17 May 2024
17
///
18
// Provides a tabular data points map with parsing and interpolation support
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
#include <map>
23
#include <string>
24
#include <vector>
25
26
// ===========================================================================
27
// class definitions
28
// ===========================================================================
29
/**
30
* @class LinearApproxHelpers
31
* @brief A generic class to operate on LinearApproxMap instances
32
*/
33
34
class LinearApproxHelpers {
35
public:
36
typedef std::map<double, double> LinearApproxMap;
37
38
/**@brief Set data points
39
* @param[in] axisString string of axis points
40
* @param[in] heightString string of height data
41
*/
42
static bool setPoints(LinearApproxMap& map, const std::string& axisString, const std::string& heightString);
43
44
/**@brief Scale both key and values
45
* @param[in] keyFactor to scale the key with
46
* @param[in] valueFactor to scale the value with
47
*/
48
static void scalePoints(LinearApproxMap& map, double keyFactor, double valueFactor);
49
50
/**@brief Scale values
51
* @param[in] factor with which to scale the values
52
*/
53
static void scaleValues(LinearApproxMap& map, const double factor);
54
55
/**@brief Set height values for existing axis values
56
* @param[in] heightString string of height data
57
*/
58
static void setValues(LinearApproxMap& map, const std::string& heightString);
59
60
/**@brief Get the smallest height value
61
* @return Minimum height value
62
*/
63
static double getMinimumValue(const LinearApproxMap& map);
64
65
/**@brief Get the largest height value
66
* @return Maximum height value
67
*/
68
static double getMaximumValue(const LinearApproxMap& map);
69
70
/**@brief Get interpolated value
71
* @param[in] axisValue axis value to get the interpolated data point for
72
*/
73
static double getInterpolatedValue(const LinearApproxMap& map, double axisValue);
74
75
/**@brief split string into data values
76
* @param[in] dataString string containing row of double values
77
*/
78
static std::vector<double> getValueTable(const std::string& dataString);
79
};
80
81