mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Fault reactivation (#10624)
Update result to generate well paths based on information from model generator. Store settings in JSON file. Add method to access local coordinate system definition
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QTextStream>
|
||||
|
||||
namespace ResInsightInternalJson
|
||||
{
|
||||
@@ -30,10 +31,14 @@ QMap<QString, QVariant> JsonReader::decodeFile( QString filePath )
|
||||
{
|
||||
QFile file;
|
||||
file.setFileName( filePath );
|
||||
file.open( QIODevice::ReadOnly );
|
||||
QByteArray byteArray = file.readAll();
|
||||
file.close();
|
||||
return Json::decode( byteArray );
|
||||
if ( file.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
QByteArray byteArray = file.readAll();
|
||||
file.close();
|
||||
return Json::decode( byteArray );
|
||||
}
|
||||
|
||||
return QMap<QString, QVariant>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -53,6 +58,25 @@ QString JsonReader::rootKeyText()
|
||||
return "root";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool JsonWriter::encodeFile( QString filePath, QMap<QString, QVariant> map )
|
||||
{
|
||||
QFile file;
|
||||
file.setFileName( filePath );
|
||||
if ( file.open( QIODevice::ReadWrite | QIODevice::Text ) )
|
||||
{
|
||||
QString content = Json::encode( map, true );
|
||||
QTextStream out( &file );
|
||||
out << content;
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -28,12 +28,24 @@ namespace ResInsightInternalJson
|
||||
class JsonReader
|
||||
{
|
||||
public:
|
||||
QMap<QString, QVariant> decodeFile( QString filePath );
|
||||
static QMap<QString, QVariant> decodeFile( QString filePath );
|
||||
|
||||
// Get a variant list from a map
|
||||
static QVariantList getVariantList( const QMap<QString, QVariant>& map );
|
||||
|
||||
static QString rootKeyText();
|
||||
|
||||
private:
|
||||
JsonReader(){};
|
||||
};
|
||||
|
||||
class JsonWriter
|
||||
{
|
||||
public:
|
||||
static bool encodeFile( QString filePath, QMap<QString, QVariant> map );
|
||||
|
||||
private:
|
||||
JsonWriter(){};
|
||||
};
|
||||
|
||||
class Json
|
||||
|
||||
@@ -124,9 +124,8 @@ bool RifWellPathImporter::isJsonFile( const QString& filePath )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifWellPathImporter::WellMetaData RifWellPathImporter::readJsonWellMetaData( const QString& filePath )
|
||||
{
|
||||
ResInsightInternalJson::JsonReader jsonReader;
|
||||
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile( filePath );
|
||||
WellMetaData metadata;
|
||||
QMap<QString, QVariant> jsonMap = ResInsightInternalJson::JsonReader::decodeFile( filePath );
|
||||
WellMetaData metadata;
|
||||
|
||||
metadata.m_id = jsonMap["id"].toString();
|
||||
metadata.m_name = jsonMap["name"].toString();
|
||||
@@ -151,8 +150,7 @@ RifWellPathImporter::WellMetaData RifWellPathImporter::readJsonWellMetaData( con
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifWellPathImporter::WellData RifWellPathImporter::readJsonWellData( const QString& filePath )
|
||||
{
|
||||
ResInsightInternalJson::JsonReader jsonReader;
|
||||
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile( filePath );
|
||||
QMap<QString, QVariant> jsonMap = ResInsightInternalJson::JsonReader::decodeFile( filePath );
|
||||
|
||||
double datumElevation = jsonMap["datumElevation"].toDouble();
|
||||
QList<QVariant> pathList = jsonMap["path"].toList();
|
||||
|
||||
Reference in New Issue
Block a user