Ascii import of Well Paths

p4#: 21956
This commit is contained in:
Jacob Støren
2013-06-18 11:56:51 +02:00
parent 2a2102837a
commit 5db88f4e03
4 changed files with 94 additions and 34 deletions

View File

@@ -40,6 +40,7 @@
#include "Rim3dOverlayInfoConfig.h"
#include "RimOilField.h"
#include "RimAnalysisModels.h"
#include <fstream>
CAF_PDM_SOURCE_INIT(RimWellPath, "WellPath");
@@ -161,44 +162,94 @@ caf::PdmFieldHandle* RimWellPath::objectToggleField()
/// Read JSON file containing well path data
//--------------------------------------------------------------------------------------------------
void RimWellPath::readWellPathFile()
{
if (filepath().endsWith(".json"), Qt::CaseInsensitive)
{
this->readJsonWellPathFile();
}
else
{
this->readAsciiWellPathFile();
}
}
//--------------------------------------------------------------------------------------------------
/// Read JSON file containing well path data
//--------------------------------------------------------------------------------------------------
void RimWellPath::readJsonWellPathFile()
{
RigWellPath* wellPathGeom = new RigWellPath();
JsonReader jsonReader;
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filepath);
// General well info
name = jsonMap["name"].toString();
id = jsonMap["id"].toString();
name = jsonMap["name"].toString();
id = jsonMap["id"].toString();
sourceSystem = jsonMap["sourceSystem"].toString();
utmZone = jsonMap["utmZone"].toString();
updateUser = jsonMap["updateUser"].toString();
setSurveyType(jsonMap["surveyType"].toString());
sourceSystem = jsonMap["sourceSystem"].toString();
utmZone = jsonMap["utmZone"].toString();
// Convert updateDate from the following format:
// "Number of milliseconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds"
// "Number of milliseconds elapsed since midnight Coordinated Universal Time (UTC)
// of January 1, 1970, not counting leap seconds"
QString updateDateStr = jsonMap["updateDate"].toString().trimmed();
uint updateDateUint = updateDateStr.toULongLong() / 1000; // should be within 32 bit, maximum number is 4294967295 which corresponds to year 2106
QDateTime updateDateTime;
updateDateTime.setTime_t(updateDateUint);
//updateDate = updateDateTime.toString(Qt::SystemLocaleShortDate);
updateDate = updateDateTime.toString("d MMMM yyyy");
updateUser = jsonMap["updateUser"].toString();
/*printf("Read JSON file: well path name = %s\n filePath = %s\n",
name().toStdString().c_str(),
(const char*) filepath().toLocal8Bit());*/
// Well path points
double datumElevation = jsonMap["datumElevation"].toDouble();
// Well path points
QList<QVariant> pathList = jsonMap["path"].toList();
foreach (QVariant point, pathList)
{
QMap<QString, QVariant> coordinateMap = point.toMap();
cvf::Vec3d vec3d(coordinateMap["east"].toDouble(), coordinateMap["north"].toDouble(), -(coordinateMap["tvd"].toDouble() - datumElevation));
wellPathGeom->m_wellPathPoints.push_back(vec3d);
//printf("Added point to well path: (%f, %f, %f)\n", vec3d.x(), vec3d.y(), vec3d.z());
}
//jsonReader.dumpToFile(wellPathGeom->m_wellPathPoints, "c:\\temp\\jsonpoints.txt");
setWellPathGeometry(wellPathGeom);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::readAsciiWellPathFile()
{
RigWellPath* wellPathGeom = new RigWellPath();
std::ifstream stream(filepath().toLatin1().data());
double x, y, tvd, md;
while(stream.good())
{
std::string wellNameKw;
stream >> wellNameKw;
while (stream.good())
{
stream >> x >> y >> tvd >> md;
if (stream.good())
{
cvf::Vec3d wellPoint(x, y, -tvd);
wellPathGeom->m_wellPathPoints.push_back(wellPoint);
}
}
if (stream.eof()) break;
stream.clear();
}
setWellPathGeometry(wellPathGeom);
}

View File

@@ -50,13 +50,7 @@ public:
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
caf::PdmField<QString> name;
caf::PdmField<QString> id;
caf::PdmField<QString> sourceSystem;
caf::PdmField<QString> utmZone;
caf::PdmField<QString> updateDate;
caf::PdmField<QString> updateUser;
void setSurveyType(QString surveyType);
QString surveyType() { return m_surveyType; }
caf::PdmField<QString> filepath;
caf::PdmField<bool> showWellPathLabel;
@@ -64,14 +58,28 @@ public:
caf::PdmField<cvf::Color3f> wellPathColor;
caf::PdmField<double> wellPathRadiusScaleFactor;
void setWellPathGeometry(RigWellPath* wellPathModel) { m_wellPath = wellPathModel; }
RigWellPath* wellPathGeometry() { return m_wellPath.p(); }
RivWellPathPartMgr* partMgr();
void readWellPathFile();
private:
void setWellPathGeometry(RigWellPath* wellPathModel) { m_wellPath = wellPathModel; }
void readJsonWellPathFile();
void readAsciiWellPathFile();
QString surveyType() { return m_surveyType; }
void setSurveyType(QString surveyType);
caf::PdmField<QString> id;
caf::PdmField<QString> sourceSystem;
caf::PdmField<QString> utmZone;
caf::PdmField<QString> updateDate;
caf::PdmField<QString> updateUser;
caf::PdmField<QString> m_surveyType;
cvf::ref<RigWellPath> m_wellPath;
cvf::ref<RivWellPathPartMgr> m_wellPathPartMgr;
caf::PdmPointer<RimWellPathCollection> m_wellPathCollection;

View File

@@ -189,8 +189,8 @@ void RiuMainWindow::createActions()
m_openProjectAction = new QAction(style()->standardIcon(QStyle::SP_DirOpenIcon), "&Open Project", this);
m_openLastUsedProjectAction = new QAction("Open &Last Used Project", this);
m_openWellPathsAction = new QAction(style()->standardIcon(QStyle::SP_DirOpenIcon), "&Open Well Paths", this);
m_importWellPathsAction = new QAction(style()->standardIcon(QStyle::SP_DriveNetIcon),"Import Well Paths", this);
m_importWellPathsFromFileAction = new QAction(QIcon(":/Well.png"), "&Import Well Paths from File", this);
m_importWellPathsFromSSIHubAction = new QAction(QIcon(":/WellCollection.png"),"Import Well Paths from &SSI-hub", this);
m_mockModelAction = new QAction("&Mock Model", this);
m_mockResultsModelAction = new QAction("Mock Model With &Results", this);
@@ -212,8 +212,8 @@ void RiuMainWindow::createActions()
connect(m_openMultipleEclipseCasesAction,SIGNAL(triggered()), SLOT(slotOpenMultipleCases()));
connect(m_openProjectAction, SIGNAL(triggered()), SLOT(slotOpenProject()));
connect(m_openLastUsedProjectAction,SIGNAL(triggered()), SLOT(slotOpenLastUsedProject()));
connect(m_openWellPathsAction, SIGNAL(triggered()), SLOT(slotOpenWellPaths()));
connect(m_importWellPathsAction, SIGNAL(triggered()), SLOT(slotImportWellPaths()));
connect(m_importWellPathsFromFileAction, SIGNAL(triggered()), SLOT(slotImportWellPathsFromFile()));
connect(m_importWellPathsFromSSIHubAction, SIGNAL(triggered()), SLOT(slotImportWellPathsFromSSIHub()));
connect(m_mockModelAction, SIGNAL(triggered()), SLOT(slotMockModel()));
connect(m_mockResultsModelAction, SIGNAL(triggered()), SLOT(slotMockResultsModel()));
@@ -303,14 +303,15 @@ void RiuMainWindow::createMenus()
fileMenu->addAction(m_openProjectAction);
fileMenu->addAction(m_openLastUsedProjectAction);
fileMenu->addAction(m_openWellPathsAction);
fileMenu->addSeparator();
QMenu* importMenu = fileMenu->addMenu("&Import");
importMenu->addAction(m_openEclipseCaseAction);
importMenu->addAction(m_openInputEclipseFileAction);
importMenu->addAction(m_openMultipleEclipseCasesAction);
importMenu->addAction(m_importWellPathsAction);
importMenu->addSeparator();
importMenu->addAction(m_importWellPathsFromFileAction);
importMenu->addAction(m_importWellPathsFromSSIHubAction);
QMenu* exportMenu = fileMenu->addMenu("&Export");
exportMenu->addAction(m_snapshotToFile);
@@ -558,7 +559,7 @@ void RiuMainWindow::slotRefreshFileActions()
bool projectFileExists = QFile::exists(app->project()->fileName());
m_importWellPathsAction->setEnabled(projectFileExists);
m_importWellPathsFromSSIHubAction->setEnabled(projectFileExists);
}
@@ -779,12 +780,12 @@ void RiuMainWindow::slotOpenLastUsedProject()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::slotOpenWellPaths()
void RiuMainWindow::slotImportWellPathsFromFile()
{
// Open dialog box to select well path files
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->defaultFileDialogDirectory("WELLPATH_DIR");
QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(this, "Open JSON Well Paths", defaultDir, "JSON Well Path (*.json)");
QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(this, "Import Well Paths", defaultDir, "JSON Well Path (*.json);;ASCII Well Paths (*.asc *.asci *.ascii)");
if (wellPathFilePaths.size() < 1) return;
@@ -1594,7 +1595,7 @@ void RiuMainWindow::selectedCases(std::vector<RimCase*>& cases)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::slotImportWellPaths()
void RiuMainWindow::slotImportWellPathsFromSSIHub()
{
CVF_ASSERT(m_ssihubInterface);

View File

@@ -124,8 +124,8 @@ private:
QAction* m_openMultipleEclipseCasesAction;
QAction* m_openProjectAction;
QAction* m_openLastUsedProjectAction;
QAction* m_openWellPathsAction;
QAction* m_importWellPathsAction;
QAction* m_importWellPathsFromFileAction;
QAction* m_importWellPathsFromSSIHubAction;
QAction* m_saveProjectAction;
QAction* m_saveProjectAsAction;
QAction* m_closeProjectAction;
@@ -184,8 +184,8 @@ private slots:
void slotOpenMultipleCases();
void slotOpenProject();
void slotOpenLastUsedProject();
void slotOpenWellPaths();
void slotImportWellPaths();
void slotImportWellPathsFromFile();
void slotImportWellPathsFromSSIHub();
void slotSaveProject();
void slotSaveProjectAs();
void slotCloseProject();