mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3089 Move text parsing for unit conversion
This commit is contained in:
@@ -125,13 +125,13 @@ QString RiaEclipseUnitTools::unitStringPressure(UnitSystem unitSystem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
double RiaEclipseUnitTools::convertToMeter(double sourceValue, const QString& unitText)
|
double RiaEclipseUnitTools::convertToMeter(double sourceValue, const QString& sourceValueUnitText)
|
||||||
{
|
{
|
||||||
QString timmed = unitText.trimmed();
|
QString timmed = sourceValueUnitText.trimmed();
|
||||||
|
|
||||||
if (timmed.compare("m", Qt::CaseInsensitive) == 0)
|
if (timmed.compare("m", Qt::CaseInsensitive) == 0 || timmed.compare("md-m", Qt::CaseInsensitive) == 0)
|
||||||
{
|
{
|
||||||
return sourceValue;
|
return sourceValue;
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ double RiaEclipseUnitTools::convertToMeter(double sourceValue, const QString& un
|
|||||||
{
|
{
|
||||||
return RiaEclipseUnitTools::inchToMeter(sourceValue);
|
return RiaEclipseUnitTools::inchToMeter(sourceValue);
|
||||||
}
|
}
|
||||||
else if (timmed.compare("ft", Qt::CaseInsensitive) == 0)
|
else if (timmed.compare("ft", Qt::CaseInsensitive) == 0 || timmed.compare("md-ft", Qt::CaseInsensitive) == 0)
|
||||||
{
|
{
|
||||||
return RiaEclipseUnitTools::feetToMeter(sourceValue);
|
return RiaEclipseUnitTools::feetToMeter(sourceValue);
|
||||||
}
|
}
|
||||||
@@ -152,13 +152,13 @@ double RiaEclipseUnitTools::convertToMeter(double sourceValue, const QString& un
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
double RiaEclipseUnitTools::convertToFeet(double sourceValue, const QString& unitText)
|
double RiaEclipseUnitTools::convertToFeet(double sourceValue, const QString& sourceValueUnitText)
|
||||||
{
|
{
|
||||||
QString timmed = unitText.trimmed();
|
QString timmed = sourceValueUnitText.trimmed();
|
||||||
|
|
||||||
if (timmed.compare("ft", Qt::CaseInsensitive) == 0)
|
if (timmed.compare("ft", Qt::CaseInsensitive) == 0 || timmed.compare("md-ft", Qt::CaseInsensitive) == 0)
|
||||||
{
|
{
|
||||||
return sourceValue;
|
return sourceValue;
|
||||||
}
|
}
|
||||||
@@ -171,11 +171,10 @@ double RiaEclipseUnitTools::convertToFeet(double sourceValue, const QString& uni
|
|||||||
double meter = sourceValue / 100.0;
|
double meter = sourceValue / 100.0;
|
||||||
return RiaEclipseUnitTools::meterToFeet(meter);
|
return RiaEclipseUnitTools::meterToFeet(meter);
|
||||||
}
|
}
|
||||||
else if (timmed.compare("m", Qt::CaseInsensitive) == 0)
|
else if (timmed.compare("m", Qt::CaseInsensitive) == 0 || timmed.compare("md-m", Qt::CaseInsensitive) == 0)
|
||||||
{
|
{
|
||||||
return RiaEclipseUnitTools::meterToFeet(sourceValue);
|
return RiaEclipseUnitTools::meterToFeet(sourceValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return HUGE_VAL;
|
return HUGE_VAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -311,27 +311,17 @@ std::vector<std::vector<double>>
|
|||||||
// The conductivity value is used in the computations of transmissibility when exporting COMPDAT, and has unit md-m or md-ft
|
// The conductivity value is used in the computations of transmissibility when exporting COMPDAT, and has unit md-m or md-ft
|
||||||
// This unit must match the unit used to represent coordinates of the grid used for export
|
// This unit must match the unit used to represent coordinates of the grid used for export
|
||||||
|
|
||||||
QString conversionUnitText;
|
|
||||||
if (conductivityUnitTextOnFile == "md-m")
|
|
||||||
{
|
|
||||||
conversionUnitText = "m";
|
|
||||||
}
|
|
||||||
else if (conductivityUnitTextOnFile == "md-ft")
|
|
||||||
{
|
|
||||||
conversionUnitText = "ft";
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& yValues : conductivityValues)
|
for (auto& yValues : conductivityValues)
|
||||||
{
|
{
|
||||||
for (auto& xVal : yValues)
|
for (auto& xVal : yValues)
|
||||||
{
|
{
|
||||||
if (requiredUnitSet == RiaEclipseUnitTools::UNITS_FIELD)
|
if (requiredUnitSet == RiaEclipseUnitTools::UNITS_FIELD)
|
||||||
{
|
{
|
||||||
xVal = RiaEclipseUnitTools::convertToFeet(xVal, conversionUnitText);
|
xVal = RiaEclipseUnitTools::convertToFeet(xVal, conductivityUnitTextOnFile);
|
||||||
}
|
}
|
||||||
else if (requiredUnitSet == RiaEclipseUnitTools::UNITS_METRIC)
|
else if (requiredUnitSet == RiaEclipseUnitTools::UNITS_METRIC)
|
||||||
{
|
{
|
||||||
xVal = RiaEclipseUnitTools::convertToMeter(xVal, conversionUnitText);
|
xVal = RiaEclipseUnitTools::convertToMeter(xVal, conductivityUnitTextOnFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user