diff --git a/FileIO/GMSInterface.cpp b/FileIO/GMSInterface.cpp index 753aa57366157f4c5cd65e21db9948eb6b4f7a7b..cdf1ce134829a9c80a1613a1be797efb4a545f05 100644 --- a/FileIO/GMSInterface.cpp +++ b/FileIO/GMSInterface.cpp @@ -126,8 +126,7 @@ void GMSInterface::writeBoreholesToGMS(const std::vector<GeoLib::Point*>* statio const std::string &filename) { std::ofstream out( filename.c_str(), std::ios::out ); - std::size_t idx = 0; - std::vector<std::string> soilID = readSoilIDfromFile("d:/BodeTimeline.txt"); + //std::vector<std::string> soilID = readSoilIDfromFile("d:/BodeTimeline.txt"); // write header out << "name" << "\t" << std::fixed << "X" << "\t" << "Y" << "\t" << "Z" << "\t" << @@ -139,62 +138,32 @@ void GMSInterface::writeBoreholesToGMS(const std::vector<GeoLib::Point*>* statio static_cast<GeoLib::StationBorehole*>((*stations)[j]); std::vector<GeoLib::Point*> profile = station->getProfile(); std::vector<std::string> soilNames = station->getSoilNames(); + //std::size_t idx = 0; + std::string current_soil_name(""); std::size_t nLayers = profile.size(); for (std::size_t i = 1; i < nLayers; i++) { if ( (i > 1) && (soilNames[i].compare(soilNames[i - 1]) == 0) ) continue; - idx = getSoilID(soilID, soilNames[i]); - - out << station->getName() << "\t" << std::fixed << - (*(profile[i - 1]))[0] << "\t" - << (*(profile[i - 1]))[1] << "\t" << (*(profile[i - 1]))[2] << "\t" - << idx << std::endl; + //idx = getSoilID(soilID, soilNames[i]); + current_soil_name = soilNames[i]; + + out << station->getName() << "\t" << std::fixed + << (*(profile[i - 1]))[0] << "\t" + << (*(profile[i - 1]))[1] << "\t" + << (*(profile[i - 1]))[2] << "\t" + << current_soil_name/*idx*/ << std::endl; } out << station->getName() << "\t" << std::fixed << (*(profile[nLayers - 1]))[0] << "\t" - << (*(profile[nLayers - - 1]))[1] << "\t" << (*(profile[nLayers - 1]))[2] << "\t" - << idx << std::endl; // this line marks the end of the borehole + << (*(profile[nLayers - 1]))[1] << "\t" + << (*(profile[nLayers - 1]))[2] << "\t" + << current_soil_name << std::endl; // this line marks the end of the borehole } out.close(); - GMSInterface::writeSoilIDTable(soilID, "d:/SoilIDReference.txt"); -} - -int GMSInterface::writeBoreholeToGMS(const GeoLib::StationBorehole* station, - const std::string &filename, - std::vector<std::string> &soilID) -{ - std::ofstream out( filename.c_str(), std::ios::out ); - std::size_t idx = 0; - - // write header - out << "name" << "\t" << std::fixed << "X" << "\t" << "Y" << "\t" << "Z" << "\t" << - "soilID" << std::endl; - - std::vector<GeoLib::Point*> profile = station->getProfile(); - std::vector<std::string> soilNames = station->getSoilNames(); - - // write table - std::size_t nLayers = profile.size(); - for (std::size_t i = 1; i < nLayers; i++) - { - if ( (i > 1) && (soilNames[i].compare(soilNames[i - 1]) == 0) ) - continue; - idx = getSoilID(soilID, soilNames[i]); - - out << station->getName() << "\t" << std::fixed << (*(profile[i - 1]))[0] << "\t" - << (*(profile[i - 1]))[1] << "\t" << (*(profile[i - 1]))[2] << "\t" - << idx << std::endl; - } - out << station->getName() << "\t" << std::fixed << (*(profile[nLayers - 1]))[0] << "\t" - << (*(profile[nLayers - 1]))[1] << "\t" << (*(profile[nLayers - 1]))[2] << "\t" - << idx << std::endl; // this line marks the end of the borehole - out.close(); - - return 1; + //GMSInterface::writeSoilIDTable(soilID, "d:/SoilIDReference.txt"); } std::size_t GMSInterface::getSoilID(std::vector<std::string> &soilID, std::string &soilName) diff --git a/FileIO/GMSInterface.h b/FileIO/GMSInterface.h index aabb9fce4666894545fd90344bdaa27f083d2945..bee92f4ff973e19aabf180865d6a0a283d667fc4 100644 --- a/FileIO/GMSInterface.h +++ b/FileIO/GMSInterface.h @@ -50,11 +50,6 @@ public: static int readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, const std::string &filename); - /// Exports borehole data from one borehole to a file in GMS-format. - static int writeBoreholeToGMS(const GeoLib::StationBorehole* station, - const std::string &filename, - std::vector<std::string> &soilID); - /// Writes a file that assigns each soilID-index in the GMS export file a name. static int writeSoilIDTable(const std::vector<std::string> &soilID, const std::string &filename); diff --git a/Gui/DataView/StationTreeView.cpp b/Gui/DataView/StationTreeView.cpp index daf5c65d554fff2e87427eec1ff825ffdcbabf83..8cb507055ffce90b8b651cf90e318c2f16ff6d4c 100644 --- a/Gui/DataView/StationTreeView.cpp +++ b/Gui/DataView/StationTreeView.cpp @@ -199,14 +199,11 @@ void StationTreeView::exportStation() if (!fileName.isEmpty()) { QString temp_name; - std::vector<std::string> temp_soil_names; - temp_soil_names.push_back(""); // soil name vector needs to be initialised - GMSInterface::writeBoreholeToGMS(static_cast<GeoLib::StationBorehole*>(static_cast< - StationTreeModel - *>( - model())->stationFromIndex(index, - temp_name)), - fileName.toStdString(), temp_soil_names); + std::vector<GeoLib::Point*> stations; + stations.push_back(static_cast<GeoLib::StationBorehole*>( + static_cast<StationTreeModel*>(model())->stationFromIndex(index,temp_name))); + GMSInterface::writeBoreholesToGMS(&stations, fileName.toStdString()); + } }