(#435) WIP - Reading metadata from LAS files

This commit is contained in:
Pål Hagen
2015-09-14 16:33:28 +02:00
parent 671506f7cc
commit 095d974e38
17 changed files with 519 additions and 4 deletions

View File

@@ -68,6 +68,8 @@ ${CEE_CURRENT_LIST_DIR}RimWellLogPlotCurve.h
${CEE_CURRENT_LIST_DIR}RimViewLinker.h
${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.h
${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.h
${CEE_CURRENT_LIST_DIR}RimWellLasFileInfo.h
${CEE_CURRENT_LIST_DIR}RimWellLasLog.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -134,6 +136,8 @@ ${CEE_CURRENT_LIST_DIR}RimWellLogPlotCurve.cpp
${CEE_CURRENT_LIST_DIR}RimViewLinker.cpp
${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.cpp
${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.cpp
${CEE_CURRENT_LIST_DIR}RimWellLasFileInfo.cpp
${CEE_CURRENT_LIST_DIR}RimWellLasLog.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -776,6 +776,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
commandIds << "RicWellPathsDeleteAllFeature";
commandIds << "RicWellPathsImportFileFeature";
commandIds << "RicWellPathsImportSsihubFeature";
commandIds << "RicWellLogsImportFileFeature";
}
else if (dynamic_cast<RimWellPath*>(uiItem))
{

View File

@@ -0,0 +1,136 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RimWellLasFileInfo.h"
#include "RimWellLasLog.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "well.hpp"
#include <QString>
#include <QFileInfo>
CAF_PDM_SOURCE_INIT(RimWellLasFileInfo, "WellLasFileInfo");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLasFileInfo::RimWellLasFileInfo()
{
CAF_PDM_InitObject("Well LAS File Info", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellName, "WellName", "", "", "", "");
m_wellName.uiCapability()->setUiReadOnly(true);
m_wellName.uiCapability()->setUiHidden(true);
m_wellName.xmlCapability()->setIOWritable(false);
CAF_PDM_InitFieldNoDefault(&m_fileName, "FileName", "Filename", "", "", "");
m_fileName.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitFieldNoDefault(&m_name, "Name", "", "", "", "");
m_name.uiCapability()->setUiReadOnly(true);
m_name.uiCapability()->setUiHidden(true);
m_name.xmlCapability()->setIOWritable(false);
CAF_PDM_InitFieldNoDefault(&m_lasFileLogs, "WellLASFileLogs", "", "", "", "");
m_lasFileLogs.uiCapability()->setUiHidden(true);
m_lasFileLogs.xmlCapability()->setIOWritable(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLasFileInfo::~RimWellLasFileInfo()
{
close();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLasFileInfo::setFileName(const QString& fileName)
{
m_fileName = fileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLasFileInfo::readFile()
{
close();
int wellFormat = NRLib::Well::LAS;
NRLib::Well* well = NRLib::Well::ReadWell(m_fileName().toStdString(), wellFormat);
if (!well)
{
// TODO: Error handling
return false;
}
m_wellName = QString::fromStdString(well->GetWellName());
m_name = QFileInfo(m_fileName).fileName();
const std::map<std::string, std::vector<double> >& contLogs = well->GetContLog();
std::vector<std::string> contLogNames;
std::map<std::string, std::vector<double> >::const_iterator itCL;
for (itCL = contLogs.begin(); itCL != contLogs.end(); itCL++)
{
RimWellLasLog* contLog = new RimWellLasLog();
contLog->setName(QString::fromStdString(itCL->first));
m_lasFileLogs.push_back(contLog);
}
// TODO: Do the same for discrete logs
RimWellPath* wellPath;
firstAnchestorOrThisOfType(wellPath);
if (wellPath)
{
if (wellPath->filepath().isEmpty())
{
wellPath->name = m_wellName;
}
}
delete well;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLasFileInfo::close()
{
m_lasFileLogs.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLasFileInfo::wellName() const
{
return m_wellName;
}

View File

@@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmChildArrayField.h"
class RimWellLasLog;
class QString;
//==================================================================================================
///
///
//==================================================================================================
class RimWellLasFileInfo : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimWellLasFileInfo();
virtual ~RimWellLasFileInfo();
void setFileName(const QString& fileName);
bool readFile();
void close();
QString wellName() const;
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; }
private:
caf::PdmChildArrayField<RimWellLasLog*> m_lasFileLogs;
private:
caf::PdmField<QString> m_wellName;
caf::PdmField<QString> m_fileName;
caf::PdmField<QString> m_name;
};

View File

@@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RimWellLasLog.h"
#include <QString>
CAF_PDM_SOURCE_INIT(RimWellLasLog, "WellLasLog");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLasLog::RimWellLasLog()
{
CAF_PDM_InitObject("Well LAS File Log", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_name, "Name", "", "", "", "");
m_name.uiCapability()->setUiHidden(true);
m_name.xmlCapability()->setIOWritable(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLasLog::setName(const QString& name)
{
m_name = name;
}

View File

@@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "cafPdmObject.h"
#include "cafPdmField.h"
class QString;
//==================================================================================================
///
///
//==================================================================================================
class RimWellLasLog : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimWellLasLog();
void setName(const QString& name);
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; }
private:
caf::PdmField<QString> m_name;
};

View File

@@ -23,6 +23,7 @@
#include "RifJsonEncodeDecode.h"
#include "RimProject.h"
#include "RimTools.h"
#include "RimWellLasFileInfo.h"
#include "RimWellPathCollection.h"
#include "RivWellPathPartMgr.h"
@@ -81,6 +82,9 @@ RimWellPath::RimWellPath()
CAF_PDM_InitField(&wellPathRadiusScaleFactor, "WellPathRadiusScale", 1.0, "Well path radius scale", "", "", "");
CAF_PDM_InitField(&wellPathColor, "WellPathColor", cvf::Color3f(0.999f, 0.333f, 0.999f), "Well path color", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_lasFileInfo, "LasFileInfo", "Las File Info", "", "", "");
m_lasFileInfo.uiCapability()->setUiHidden(true);
m_wellPath = NULL;
m_project = NULL;
}
@@ -91,6 +95,10 @@ RimWellPath::RimWellPath()
//--------------------------------------------------------------------------------------------------
RimWellPath::~RimWellPath()
{
if (m_lasFileInfo)
{
delete m_lasFileInfo;
}
}
@@ -164,6 +172,29 @@ void RimWellPath::readWellPathFile()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLasFileInfo* RimWellPath::readWellLogFile(const QString& logFilePath)
{
QFileInfo fi(logFilePath);
RimWellLasFileInfo* lasFileInfo = NULL;
if (fi.suffix().compare("las") == 0)
{
lasFileInfo = new RimWellLasFileInfo();
lasFileInfo->setFileName(logFilePath);
if (!lasFileInfo->readFile())
{
delete lasFileInfo;
lasFileInfo = NULL;
}
}
return lasFileInfo;
}
//--------------------------------------------------------------------------------------------------
/// Read JSON file containing well path data
//--------------------------------------------------------------------------------------------------
@@ -245,7 +276,6 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
ssihubGroup->add(&updateDate);
ssihubGroup->add(&updateUser);
ssihubGroup->add(&m_surveyType);
}
//--------------------------------------------------------------------------------------------------
@@ -323,3 +353,18 @@ void RimWellPath::updateFilePathsFromProjectPath()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::setLogFileInfo(RimWellLasFileInfo* logFileInfo)
{
if (m_lasFileInfo)
{
delete m_lasFileInfo;
}
m_lasFileInfo = logFileInfo;
m_lasFileInfo->uiCapability()->setUiHidden(true);
this->name = m_lasFileInfo->wellName();
}

View File

@@ -23,6 +23,7 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmChildField.h"
#include "cafAppEnum.h"
// Include to make Pdm work for cvf::Color
@@ -33,6 +34,7 @@
class RimProject;
class RivWellPathPartMgr;
class RimWellPathCollection;
class RimWellLasFileInfo;
//==================================================================================================
///
@@ -48,6 +50,7 @@ public:
void setProject(RimProject* project) { m_project = project; }
void setCollection(RimWellPathCollection* collection) { m_wellPathCollection = collection; }
void setLogFileInfo(RimWellLasFileInfo* logFileInfo);
virtual caf::PdmFieldHandle* userDescriptionField();
virtual caf::PdmFieldHandle* objectToggleField();
@@ -65,10 +68,13 @@ public:
caf::PdmField<cvf::Color3f> wellPathColor;
caf::PdmField<double> wellPathRadiusScaleFactor;
caf::PdmChildField<RimWellLasFileInfo*> m_lasFileInfo;
RigWellPath* wellPathGeometry() { return m_wellPath.p(); }
RivWellPathPartMgr* partMgr();
void readWellPathFile();
static RimWellLasFileInfo* readWellLogFile(const QString& logFilePath);
void updateFilePathsFromProjectPath();
@@ -99,5 +105,5 @@ private:
cvf::ref<RigWellPath> m_wellPath;
cvf::ref<RivWellPathPartMgr> m_wellPathPartMgr;
caf::PdmPointer<RimWellPathCollection> m_wellPathCollection;
RimProject* m_project;
RimProject* m_project;
};

View File

@@ -24,6 +24,7 @@
#include "RiaPreferences.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellLasFileInfo.h"
#include "RivWellPathCollectionPartMgr.h"
#include "cafPdmUiEditorHandle.h"
@@ -81,7 +82,6 @@ RimWellPathCollection::RimWellPathCollection()
m_project = NULL;
m_asciiFileReader = new RimWellPathAsciiFileReader;
}
@@ -127,7 +127,15 @@ void RimWellPathCollection::readWellPathFiles()
for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++)
{
wellPaths[wpIdx]->readWellPathFile();
if (!wellPaths[wpIdx]->filepath().isEmpty())
{
wellPaths[wpIdx]->readWellPathFile();
}
if (wellPaths[wpIdx]->m_lasFileInfo)
{
wellPaths[wpIdx]->m_lasFileInfo->readFile();
}
progress.setProgressDescription(QString("Reading file %1").arg(wellPaths[wpIdx]->name));
progress.incrementProgress();
@@ -192,6 +200,26 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths )
readWellPathFiles();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::addWellLogs(const QStringList& filePaths)
{
foreach (QString filePath, filePaths)
{
RimWellLasFileInfo* logFileInfo = RimWellPath::readWellLogFile(filePath);
if (logFileInfo)
{
// TODO: Check for existing well paths and add log to correct well path if existing
RimWellPath* wellPath = new RimWellPath();
wellPath->setCollection(this);
wellPaths.push_back(wellPath);
wellPath->setLogFileInfo(logFileInfo);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -81,6 +81,8 @@ public:
void readWellPathFiles();
void addWellPaths(QStringList filePaths);
RimWellPathAsciiFileReader* asciiFileReader() {return m_asciiFileReader;}
void addWellLogs(const QStringList& filePaths);
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
@@ -98,6 +100,10 @@ private:
};
//==================================================================================================
///
///
//==================================================================================================
class RimWellPathAsciiFileReader
{
public: