diff --git a/ApplicationCode/ssihubInterface/ssihubDialog.cpp b/ApplicationCode/ssihubInterface/ssihubDialog.cpp index 0870f303e1..f97cddec40 100644 --- a/ApplicationCode/ssihubInterface/ssihubDialog.cpp +++ b/ApplicationCode/ssihubInterface/ssihubDialog.cpp @@ -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(m_north))); + m_southLineEdit->setText(QString::number(static_cast(m_south))); + m_eastLineEdit->setText(QString::number(static_cast(m_east))); + m_westLineEdit->setText(QString::number(static_cast(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 jsonMap = jsonReader.decodeFile(filename); + + QMapIterator it(jsonMap); + while (it.hasNext()) + { + it.next(); + + QString key = it.key(); + if (key[0].isDigit()) + { + QMap slotMap = it.value().toMap(); + QMap linkMap = slotMap["links"].toMap(); + QString entity = linkMap["entity"].toString(); + entities.push_back(entity); + } + } + + /* + QList slotList = jsonMap["slot"].toList(); + foreach (QVariant slot, slotList) + { + QMap slotMap = slot.toMap(); + QString entity = slotMap["entity"].toString(); + entities.push_back(entity); + } + */ + } + + return entities; +} + } // namespace ssihub diff --git a/ApplicationCode/ssihubInterface/ssihubDialog.h b/ApplicationCode/ssihubInterface/ssihubDialog.h index 38611affc1..19b0157476 100644 --- a/ApplicationCode/ssihubInterface/ssihubDialog.h +++ b/ApplicationCode/ssihubInterface/ssihubDialog.h @@ -76,6 +76,8 @@ private: QString getValue(const QString& key, const QString& wellPathFileContent); + QStringList filteredWellEntities(); + private slots: void downloadUtmFilterInfo(); void downloadWellPaths(); diff --git a/ApplicationCode/ssihubInterface/ssihubInterface.cpp b/ApplicationCode/ssihubInterface/ssihubInterface.cpp index b66e5fcece..f1487766b3 100644 --- a/ApplicationCode/ssihubInterface/ssihubInterface.cpp +++ b/ApplicationCode/ssihubInterface/ssihubInterface.cpp @@ -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) diff --git a/ApplicationCode/ssihubInterfaceTestApp/main.cpp b/ApplicationCode/ssihubInterfaceTestApp/main.cpp index 409704c60d..3add38d2b4 100644 --- a/ApplicationCode/ssihubInterfaceTestApp/main.cpp +++ b/ApplicationCode/ssihubInterfaceTestApp/main.cpp @@ -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);