-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parser for OSDU-style well trajectory csv.
- Loading branch information
Showing
9 changed files
with
233 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
///////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (C) 2024 Equinor ASA | ||
// | ||
// ResInsight is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> | ||
// for more details. | ||
// | ||
///////////////////////////////////////////////////////////////////////////////// | ||
|
||
#include "RifOsduWellPathReader.h" | ||
|
||
#include "RiaTextStringTools.h" | ||
|
||
#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" | ||
|
||
#include "RifCsvUserDataParser.h" | ||
|
||
#include "RigWellPath.h" | ||
|
||
#include "cvfObject.h" | ||
#include "cvfVector3.h" | ||
|
||
#include <QFileInfo> | ||
#include <QTextStream> | ||
|
||
std::pair<cvf::ref<RigWellPath>, QString> RifOsduWellPathReader::parseCsv( const QString& content ) | ||
{ | ||
QString errorMessage; | ||
RifCsvUserDataPastedTextParser parser( content, &errorMessage ); | ||
|
||
AsciiDataParseOptions parseOptions; | ||
parseOptions.cellSeparator = ","; | ||
parseOptions.decimalSeparator = "."; | ||
|
||
std::vector<std::pair<QString, std::vector<double>>> readValues; | ||
|
||
if ( parser.parse( parseOptions ) ) | ||
{ | ||
for ( auto s : parser.tableData().columnInfos() ) | ||
{ | ||
if ( s.dataType != Column::NUMERIC ) continue; | ||
|
||
QString columnName = QString::fromStdString( s.columnName() ); | ||
bool isNumber = false; | ||
auto value = columnName.toDouble( &isNumber ); | ||
std::vector<double> values = s.values; | ||
if ( isNumber ) | ||
{ | ||
values.insert( values.begin(), value ); | ||
} | ||
readValues.push_back( { columnName, values } ); | ||
} | ||
} | ||
|
||
const int MD_INDEX = 0; | ||
const int TVD_INDEX = 1; | ||
const int X_INDEX = 4; | ||
const int Y_INDEX = 5; | ||
|
||
if ( readValues.size() == 10 ) | ||
{ | ||
const size_t firstSize = readValues[MD_INDEX].second.size(); | ||
if ( ( firstSize == readValues[TVD_INDEX].second.size() ) && ( firstSize == readValues[X_INDEX].second.size() ) && | ||
( firstSize == readValues[Y_INDEX].second.size() ) ) | ||
{ | ||
std::vector<cvf::Vec3d> wellPathPoints; | ||
std::vector<double> measuredDepths; | ||
|
||
for ( size_t i = 0; i < firstSize; i++ ) | ||
{ | ||
cvf::Vec3d point( readValues[X_INDEX].second[i], readValues[Y_INDEX].second[i], -readValues[TVD_INDEX].second[i] ); | ||
double md = readValues[MD_INDEX].second[i]; | ||
|
||
wellPathPoints.push_back( point ); | ||
measuredDepths.push_back( md ); | ||
} | ||
|
||
return { new RigWellPath( wellPathPoints, measuredDepths ), "" }; | ||
} | ||
} | ||
|
||
return { nullptr, "Oh no!" }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
///////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (C) 2024- Equinor ASA | ||
// | ||
// ResInsight is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> | ||
// for more details. | ||
// | ||
///////////////////////////////////////////////////////////////////////////////// | ||
|
||
#pragma once | ||
|
||
#include <QString> | ||
|
||
#include "cvfObject.h" | ||
|
||
class RigWellPath; | ||
|
||
//================================================================================================== | ||
// | ||
// | ||
//================================================================================================== | ||
class RifOsduWellPathReader | ||
{ | ||
public: | ||
static std::pair<cvf::ref<RigWellPath>, QString> parseCsv( const QString& content ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
ApplicationLibCode/UnitTests/RifOsduWellPathReader-Test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
///////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (C) 2024- Equinor ASA | ||
// | ||
// ResInsight is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> | ||
// for more details. | ||
// | ||
///////////////////////////////////////////////////////////////////////////////// | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "RifOsduWellPathReader.h" | ||
|
||
#include "RigWellPath.h" | ||
|
||
#include "cvfObject.h" | ||
|
||
TEST( RifOsduWellPathReader, ParseCsv ) | ||
{ | ||
std::string fileContent = R"( | ||
MD,TVD,AZIMUTH,INCLINATION,X,Y,GODLEG_SEVERITY,DX,DY,UWI,WELLBORE,CRS,EPSG_CODE | ||
0.0,0.0,1e-10,0.0,68.8767382,33.1345775,0.0,0.0,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
271.49,271.49,1e-10,0.0,68.8767382,33.1345775,0.0,0.0,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
306.29,306.29,272.01823962,0.08968724,68.8767375,33.1345774,0.24,-0.06,-0.01,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
336.29,336.29,274.30140794,0.15846019,68.8767368,33.1345775,0.22,-0.12,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
366.29,366.29,278.8234303,0.09299958,68.8767359,33.1345775,0.23,-0.2,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
396.29,396.29,272.75661039,0.10458399,68.8767352,33.1345775,0.11,-0.26,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
426.56,426.29,268.84493373,0.12982945,68.8767347,33.1345775,0.24,-0.3,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
456.29,456.29,247.08294017,0.24449049,68.8767336,33.1345774,0.58,-0.39,-0.01,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
486.29,486.28,228.45433687,1.77934187,68.876729,33.1345746,1.0,-0.78,-0.33,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
516.29,516.25,234.24032672,3.25969626,68.8767165,33.1345672,1.41,-1.85,-1.15,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
546.29,546.17,235.37605057,5.34499442,68.8766954,33.1345561,3.39,-3.64,-2.39,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
576.29,575.97,233.86086873,7.54998951,68.8766625,33.1345381,1.98,-6.44,-4.4,WELL NAME #1,WELL NAME #1,WGS84,4326 | ||
)"; | ||
|
||
QString fileContentAsQString = QString::fromStdString( fileContent ); | ||
|
||
auto [wellPath, errorMessage] = RifOsduWellPathReader::parseCsv( fileContentAsQString ); | ||
EXPECT_TRUE( wellPath.notNull() ); | ||
|
||
EXPECT_EQ( 12u, wellPath->wellPathPoints().size() ); | ||
EXPECT_EQ( 12u, wellPath->measuredDepths().size() ); | ||
|
||
cvf::Vec3d point = wellPath->wellPathPoints()[6]; | ||
EXPECT_DOUBLE_EQ( 68.8767347, point.x() ); | ||
EXPECT_DOUBLE_EQ( 33.1345775, point.y() ); | ||
EXPECT_DOUBLE_EQ( -426.29, point.z() ); | ||
|
||
EXPECT_DOUBLE_EQ( 426.56, wellPath->measuredDepths()[6] ); | ||
} |