/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file LinearApproxHelpers.h14/// @author Mirko Barthauer15/// @date 17 May 202416///17// Provides a tabular data points map with parsing and interpolation support18/****************************************************************************/19#pragma once20#include <config.h>21#include <map>22#include <string>23#include <vector>2425// ===========================================================================26// class definitions27// ===========================================================================28/**29* @class LinearApproxHelpers30* @brief A generic class to operate on LinearApproxMap instances31*/3233class LinearApproxHelpers {34public:35typedef std::map<double, double> LinearApproxMap;3637/**@brief Set data points38* @param[in] axisString string of axis points39* @param[in] heightString string of height data40*/41static bool setPoints(LinearApproxMap& map, const std::string& axisString, const std::string& heightString);4243/**@brief Scale both key and values44* @param[in] keyFactor to scale the key with45* @param[in] valueFactor to scale the value with46*/47static void scalePoints(LinearApproxMap& map, double keyFactor, double valueFactor);4849/**@brief Scale values50* @param[in] factor with which to scale the values51*/52static void scaleValues(LinearApproxMap& map, const double factor);5354/**@brief Set height values for existing axis values55* @param[in] heightString string of height data56*/57static void setValues(LinearApproxMap& map, const std::string& heightString);5859/**@brief Get the smallest height value60* @return Minimum height value61*/62static double getMinimumValue(const LinearApproxMap& map);6364/**@brief Get the largest height value65* @return Maximum height value66*/67static double getMaximumValue(const LinearApproxMap& map);6869/**@brief Get interpolated value70* @param[in] axisValue axis value to get the interpolated data point for71*/72static double getInterpolatedValue(const LinearApproxMap& map, double axisValue);7374/**@brief split string into data values75* @param[in] dataString string containing row of double values76*/77static std::vector<double> getValueTable(const std::string& dataString);78};798081