34 throw ProcessError(
TL(
"Cannot determine the minimum value from an empty map."));
36 double minValue = std::numeric_limits<double>::max();
37 for (
const auto& item : map) {
38 if (item.second < minValue) {
39 minValue = item.second;
49 throw ProcessError(
TL(
"Cannot determine the maximum value from an empty map."));
51 double maxValue = std::numeric_limits<double>::min();
52 for (
const auto& item : map) {
53 if (item.second > maxValue) {
54 maxValue = item.second;
63 LinearApproxHelpers::LinearApproxMap::const_iterator low, prev;
64 low = map.lower_bound(axisValue);
65 if (low == map.end()) {
66 return (map.rbegin())->second;
68 if (low == map.begin()) {
73 double range = low->first - prev->first;
74 double dist = axisValue - prev->first;
77 double weight = dist / range;
78 double res = (1 - weight) * prev->second + weight * low->second;
85 std::vector<double> result;
86 if (!dataString.empty()) {
99 if (heightData.size() > 0 && heightData.size() != axisData.size()) {
100 throw ProcessError(
TLF(
"Mismatching data rows of % axis and % height values.", axisData.size(), heightData.size()));
102 auto itA = axisData.begin();
103 auto itB = heightData.begin();
104 for (; itA != axisData.end() && itB != heightData.end(); ++itA, ++itB) {
105 map.insert({ *itA, *itB });
115 for (
const auto& item : map) {
116 map2[item.first * keyFactor] = item.second * valueFactor;
124 for (
auto& p : map) {
131 std::vector<double> heightData =
getValueTable(heightString);
132 if (heightData.size() > 0 && heightData.size() != map.size()) {
133 throw ProcessError(
TLF(
"Mismatching data rows of % axis and % height values.", map.size(), heightData.size()));
135 std::vector<double>::const_iterator heightIt = heightData.begin();
136 for (
auto& p : map) {
137 p.second = *heightIt;
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.
std::vector< std::string > getVector()
return vector of strings
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter