#1997 RFT plot. Improve well path and simulation path matching

This commit is contained in:
Bjørn Erik Jensen
2017-10-17 17:07:51 +02:00
parent 646c4aa9d7
commit bae1fcfa9e
2 changed files with 38 additions and 19 deletions

View File

@@ -50,6 +50,8 @@
#include <QFileInfo>
#include <QMessageBox>
#include <regex>
CAF_PDM_SOURCE_INIT(RimWellPath, "WellPath");
//--------------------------------------------------------------------------------------------------
@@ -641,31 +643,29 @@ int RimWellPath::relatedSimulationWellBranch() const
//--------------------------------------------------------------------------------------------------
bool RimWellPath::tryAssociateWithSimulationWell()
{
if (!m_simWellName().isEmpty()) return false;
RimProject* proj = RiaApplication::instance()->project();
const std::vector<QString>& simWellNames = proj->simulationWellNames();
if (!m_simWellName().isEmpty()) return false;
if (simWellNames.empty()) return false;
QString wellPathName = QString(m_name);
// Try exact name match
for (const auto& simWellName : simWellNames)
{
if (QString::compare(simWellName, m_name, Qt::CaseInsensitive) == 0)
{
m_simWellName = simWellName;
return true;
}
}
if (tryMatchName(wellPathName, simWellNames)) return true;
// Try matching ignoring spaces
QString wpName = QString(m_name).remove(' ');
for (const auto& simWellName : simWellNames)
{
if (QString::compare(simWellName, wpName, Qt::CaseInsensitive) == 0)
{
m_simWellName = simWellName;
return true;
}
}
wellPathName = QString(m_name).remove(' ');
if (tryMatchName(wellPathName, simWellNames)) return true;
// Try to remove prefix on the format 'xxxx/xx-'
std::regex pattern("^\\d*[/]\\d*-");
wellPathName = QString::fromStdString(std::regex_replace(m_name().toStdString(), pattern, ""));
if (tryMatchName(wellPathName, simWellNames)) return true;
wellPathName = wellPathName.remove(' ');
if (tryMatchName(wellPathName, simWellNames)) return true;
return false;
}
@@ -677,3 +677,21 @@ bool RimWellPath::isAssociatedWithSimulationWell() const
{
return !m_simWellName().isEmpty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellPath::tryMatchName(QString wellPathName, const std::vector<QString>& simWellNames)
{
if (wellPathName.isEmpty()) return false;
for (const auto& simWellName : simWellNames)
{
if (QString::compare(simWellName, wellPathName, Qt::CaseInsensitive) == 0)
{
m_simWellName = simWellName;
return true;
}
}
return false;
}

View File

@@ -118,6 +118,7 @@ public:
int relatedSimulationWellBranch() const;
bool tryAssociateWithSimulationWell();
bool isAssociatedWithSimulationWell() const;
bool tryMatchName(QString wellPathName, const std::vector<QString>& simWellNames);
private: