Added prototype of UTM area filtering

p4#: 21788
This commit is contained in:
Magne Sjaastad 2013-05-31 15:37:52 +02:00
parent d371c58772
commit 724d283565
4 changed files with 88 additions and 16 deletions

View File

@ -536,6 +536,13 @@ void FetchWellPathsDialog::updateFromDownloadedFiles()
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::extractAndUpdateSingleWellFiles()
{
QStringList filtereEntities;
if (m_filterWellsByUtmArea->isChecked())
{
filtereEntities = filteredWellEntities();
}
QString filename = jsonWellPathsFilePath();
QFile file(filename);
@ -576,24 +583,31 @@ void FetchWellPathsDialog::extractAndUpdateSingleWellFiles()
// Write out a single well path
{
QString singleWellPath = fileContent.mid(singleWellPathStart, pos - singleWellPathStart);
QString singleWellPathName = getValue("well", singleWellPath);
QUuid guid = QUuid::createUuid();
QString singleWellPathFilePath = m_destinationFolder + QString("/wellpath_%1.json").arg(guid);
QFile outputFile(singleWellPathFilePath);
if (outputFile.open(QIODevice::WriteOnly | QIODevice::Text))
if (m_filterWellsByUtmArea->isChecked() && filtereEntities.indexOf(singleWellPathName) < 0)
{
QTextStream out(&outputFile);
out << singleWellPath;
// Outside UTM area
}
outputFile.close();
QString key = "\"name\"";
QString wellPathName = getValue(key, singleWellPath);
if (wellPathFileNames.indexOf(singleWellPathFilePath) < 0)
else
{
wellPathNames.push_back(wellPathName);
wellPathFileNames.push_back(singleWellPathFilePath);
QUuid guid = QUuid::createUuid();
QString singleWellPathFilePath = m_destinationFolder + QString("/wellpath_%1.json").arg(guid);
QFile outputFile(singleWellPathFilePath);
if (outputFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream out(&outputFile);
out << singleWellPath;
}
outputFile.close();
QString wellPathName = getValue("name", singleWellPath);
if (wellPathFileNames.indexOf(singleWellPathFilePath) < 0)
{
wellPathNames.push_back(wellPathName);
wellPathFileNames.push_back(singleWellPathFilePath);
}
}
}
@ -649,10 +663,12 @@ void FetchWellPathsDialog::showEvent(QShowEvent* event)
//--------------------------------------------------------------------------------------------------
QString FetchWellPathsDialog::getValue(const QString& key, const QString& wellPathFileContent)
{
int pos = wellPathFileContent.indexOf(key);
QString quotedKey = "\"" + key + "\"";
int pos = wellPathFileContent.indexOf(quotedKey);
if (pos >=0)
{
int valueStartPos = wellPathFileContent.indexOf("\"", pos + key.size());
int valueStartPos = wellPathFileContent.indexOf("\"", pos + quotedKey.size());
int valueEndPos = wellPathFileContent.indexOf("\"", valueStartPos + 1);
if (valueStartPos >= 0 && valueEndPos > valueStartPos)
@ -673,6 +689,11 @@ void FetchWellPathsDialog::setRegion(int north, int south, int east, int west)
m_south = south;
m_east = east;
m_west = west;
m_northLineEdit->setText(QString::number(static_cast<int>(m_north)));
m_southLineEdit->setText(QString::number(static_cast<int>(m_south)));
m_eastLineEdit->setText(QString::number(static_cast<int>(m_east)));
m_westLineEdit->setText(QString::number(static_cast<int>(m_west)));
}
@ -700,6 +721,48 @@ void FetchWellPathsDialog::issueHttpRequestToFile(QString completeUrlText, QStri
startRequest(url);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList FetchWellPathsDialog::filteredWellEntities()
{
QStringList entities;
QString filename = jsonWellsByArea();
if (QFile::exists(filename))
{
JsonReader jsonReader;
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filename);
QMapIterator<QString, QVariant> it(jsonMap);
while (it.hasNext())
{
it.next();
QString key = it.key();
if (key[0].isDigit())
{
QMap<QString, QVariant> slotMap = it.value().toMap();
QMap<QString, QVariant> linkMap = slotMap["links"].toMap();
QString entity = linkMap["entity"].toString();
entities.push_back(entity);
}
}
/*
QList<QVariant> slotList = jsonMap["slot"].toList();
foreach (QVariant slot, slotList)
{
QMap<QString, QVariant> slotMap = slot.toMap();
QString entity = slotMap["entity"].toString();
entities.push_back(entity);
}
*/
}
return entities;
}
} // namespace ssihub

View File

@ -76,6 +76,8 @@ private:
QString getValue(const QString& key, const QString& wellPathFileContent);
QStringList filteredWellEntities();
private slots:
void downloadUtmFilterInfo();
void downloadWellPaths();

View File

@ -72,6 +72,7 @@ QStringList Interface::jsonWellPaths()
FetchWellPathsDialog fetchWellPaths;
fetchWellPaths.setSsiHubUrl(m_webServiceAddress);
fetchWellPaths.setDestinationFolder(m_jsonDestinationFolder);
fetchWellPaths.setRegion(m_north, m_south, m_east, m_west);
QStringList importedWellPathFiles;
if (fetchWellPaths.exec() == QDialog::Accepted)

View File

@ -55,6 +55,12 @@ int main(int argc, char *argv[])
wsInterface.setWebServiceAddress(wsAddress);
wsInterface.setJsonDestinationFolder(destinationFolder);
int north = 7500000;
int south = 7000000;
int east = 401000;
int west = 400000;
wsInterface.setRegion(north, south, east, west);
QStringList jsonWellPathFileNames = wsInterface.jsonWellPaths();
// void setWebServiceAddress(const QString wsAdress);