Eclipse SUMO - Simulation of Urban MObility
LinearApproxHelpers.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 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 /****************************************************************************/
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 // ===========================================================================
35 public:
36  typedef std::map<double, double> LinearApproxMap;
37 
42  static bool setPoints(LinearApproxMap& map, const std::string& axisString, const std::string& heightString);
43 
48  static void scalePoints(LinearApproxMap& map, double keyFactor, double valueFactor);
49 
53  static void scaleValues(LinearApproxMap& map, const double factor);
54 
58  static void setValues(LinearApproxMap& map, const std::string& heightString);
59 
63  static double getMinimumValue(const LinearApproxMap& map);
64 
68  static double getMaximumValue(const LinearApproxMap& map);
69 
73  static double getInterpolatedValue(const LinearApproxMap& map, double axisValue);
74 
78  static std::vector<double> getValueTable(const std::string& dataString);
79 };
A generic class to operate on LinearApproxMap instances.
std::map< double, double > LinearApproxMap
static double getInterpolatedValue(const LinearApproxMap &map, double axisValue)
Get interpolated value.
static void setValues(LinearApproxMap &map, const std::string &heightString)
Set height values for existing axis values.
static void scalePoints(LinearApproxMap &map, double keyFactor, double valueFactor)
Scale both key and values.
static void scaleValues(LinearApproxMap &map, const double factor)
Scale values.
static bool setPoints(LinearApproxMap &map, const std::string &axisString, const std::string &heightString)
Set data points.
static std::vector< double > getValueTable(const std::string &dataString)
split string into data values
static double getMaximumValue(const LinearApproxMap &map)
Get the largest height value.
static double getMinimumValue(const LinearApproxMap &map)
Get the smallest height value.