Skip to content
Snippets Groups Projects
Commit 7c58641e authored by Karsten Rink's avatar Karsten Rink
Browse files

Removed hardcoded paths for soilID/soilName relations in GMS Borehole export. This fixes #74

parent 7499ce3b
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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);
......
......@@ -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());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment