From 7728973ddc559fe0700c42246ea5c068e5f75ad4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Oct 2026 16:23:52 +0200 Subject: [PATCH] #12674: Export TVDMSL in the depth unit of the curve TVDMSL was always written with unit M and the comment 'True vertical depth in meters', also for a FIELD case whose values are in feet. RigLasFileExporter now writes TVDMSL with the depth unit of the curve, as it already does for DEPTH and TVDRKB. Compute the LAS unit string once via a depthUnitString() helper and reuse it for DEPTH, TVDMSL, TVDRKB and setDepthUnit, instead of repeating the unit if/else chain for each quantity. --- .../ReservoirDataModel/RigLasFileExporter.cpp | 55 +++++++++---------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/RigLasFileExporter.cpp b/ApplicationLibCode/ReservoirDataModel/RigLasFileExporter.cpp index 5f97e7f2b6..4c07bdb478 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigLasFileExporter.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigLasFileExporter.cpp @@ -172,23 +172,25 @@ public: lasFile->addWellInfo( "DATE", wellLogDate.toStdString() ); const RigWellLogCurveData& firstCurveData = curveDataForFirstCurve(); + const std::string depthUnitStr = depthUnitString( firstCurveData.depthUnit() ); + std::string depthComment = "Depth in Connection number"; if ( firstCurveData.depthUnit() == RiaDefines::DepthUnitType::UNIT_METER ) - { - lasFile->AddLog( "DEPTH", "M", "Depth in meters", firstCurveData.depths( RiaDefines::DepthType::MEASURED_DEPTH ) ); - } + depthComment = "Depth in meters"; else if ( firstCurveData.depthUnit() == RiaDefines::DepthUnitType::UNIT_FEET ) - { - lasFile->AddLog( "DEPTH", "FT", "Depth in feet", firstCurveData.depths( RiaDefines::DepthType::MEASURED_DEPTH ) ); - } - else if ( firstCurveData.depthUnit() == RiaDefines::DepthUnitType::UNIT_NONE ) - { - lasFile->AddLog( "DEPTH", "", "Depth in Connection number", firstCurveData.depths( RiaDefines::DepthType::MEASURED_DEPTH ) ); - } + depthComment = "Depth in feet"; + + lasFile->AddLog( "DEPTH", depthUnitStr, depthComment, firstCurveData.depths( RiaDefines::DepthType::MEASURED_DEPTH ) ); if ( !firstCurveData.depths( RiaDefines::DepthType::TRUE_VERTICAL_DEPTH ).empty() ) { - lasFile->AddLog( "TVDMSL", "M", "True vertical depth in meters", firstCurveData.depths( RiaDefines::DepthType::TRUE_VERTICAL_DEPTH ) ); + std::string tvdmslComment = "True vertical depth"; + if ( firstCurveData.depthUnit() == RiaDefines::DepthUnitType::UNIT_METER ) + tvdmslComment = "True vertical depth in meters"; + else if ( firstCurveData.depthUnit() == RiaDefines::DepthUnitType::UNIT_FEET ) + tvdmslComment = "True vertical depth in feet"; + + lasFile->AddLog( "TVDMSL", depthUnitStr, tvdmslComment, firstCurveData.depths( RiaDefines::DepthType::TRUE_VERTICAL_DEPTH ) ); if ( m_exportTvdrkb && m_rkbDiff != -1.0 ) { @@ -199,19 +201,8 @@ public: value += m_rkbDiff; } - if ( firstCurveData.depthUnit() == RiaDefines::DepthUnitType::UNIT_METER ) - { - lasFile->AddLog( "TVDRKB", "M", "True vertical depth (Rotary Kelly Bushing)", tvdrkbValues ); - } - else if ( firstCurveData.depthUnit() == RiaDefines::DepthUnitType::UNIT_FEET ) - { - lasFile->AddLog( "TVDRKB", "FT", "True vertical depth (Rotary Kelly Bushing)", tvdrkbValues ); - } - else if ( firstCurveData.depthUnit() == RiaDefines::DepthUnitType::UNIT_NONE ) - { - CAF_ASSERT( false ); - lasFile->AddLog( "TVDRKB", "", "", tvdrkbValues ); - } + CAF_ASSERT( firstCurveData.depthUnit() != RiaDefines::DepthUnitType::UNIT_NONE ); + lasFile->AddLog( "TVDRKB", depthUnitStr, "True vertical depth (Rotary Kelly Bushing)", tvdrkbValues ); } } @@ -222,13 +213,9 @@ public: lasFile->setStartDepth( minDepth ); lasFile->setStopDepth( maxDepth ); - if ( firstCurveData.depthUnit() == RiaDefines::DepthUnitType::UNIT_METER ) + if ( firstCurveData.depthUnit() != RiaDefines::DepthUnitType::UNIT_NONE ) { - lasFile->setDepthUnit( "M" ); - } - else if ( firstCurveData.depthUnit() == RiaDefines::DepthUnitType::UNIT_FEET ) - { - lasFile->setDepthUnit( "FT" ); + lasFile->setDepthUnit( depthUnitStr ); } double absentValue = SingleLasFileMetaData::createAbsentValue( m_minimumCurveValue ); @@ -248,6 +235,14 @@ private: return m_logCurveData[0].curveData(); } + static std::string depthUnitString( RiaDefines::DepthUnitType depthUnit ) + { + if ( depthUnit == RiaDefines::DepthUnitType::UNIT_METER ) return "M"; + if ( depthUnit == RiaDefines::DepthUnitType::UNIT_FEET ) return "FT"; + + return ""; + } + static double createAbsentValue( double lowestDataValue ) { double absentValue = -999.0;