From 7913fda9cb4742a2f024ded6bff3c25c879c78db Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Mon, 21 Jun 2021 13:19:06 +0200
Subject: [PATCH] [GL/StationBorehole] Use constructor to init attributes.

---
 GeoLib/StationBorehole.cpp | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/GeoLib/StationBorehole.cpp b/GeoLib/StationBorehole.cpp
index 5ed333f808b..810517705a1 100644
--- a/GeoLib/StationBorehole.cpp
+++ b/GeoLib/StationBorehole.cpp
@@ -53,22 +53,23 @@ StationBorehole::~StationBorehole()
 
 StationBorehole* StationBorehole::createStation(const std::string& line)
 {
-    StationBorehole* borehole = new StationBorehole();
+    StationBorehole* borehole = nullptr;
     std::list<std::string> fields = BaseLib::splitString(line, '\t');
 
     if (fields.size() >= 5)
     {
-        borehole->_name = fields.front();
+        auto name = fields.front();
         fields.pop_front();
-        (*borehole)[0] = strtod(
+        auto const x = strtod(
             BaseLib::replaceString(",", ".", fields.front()).c_str(), nullptr);
         fields.pop_front();
-        (*borehole)[1] = strtod(
+        auto const y = strtod(
             BaseLib::replaceString(",", ".", fields.front()).c_str(), nullptr);
         fields.pop_front();
-        (*borehole)[2] = strtod(
+        auto const z = strtod(
             BaseLib::replaceString(",", ".", fields.front()).c_str(), nullptr);
         fields.pop_front();
+        borehole = new StationBorehole(x, y, z, name);
         borehole->_depth = strtod(
             BaseLib::replaceString(",", ".", fields.front()).c_str(), nullptr);
         fields.pop_front();
@@ -98,11 +99,7 @@ StationBorehole* StationBorehole::createStation(const std::string& name,
                                                 double depth,
                                                 const std::string& date)
 {
-    StationBorehole* station = new StationBorehole();
-    station->_name = name;
-    (*station)[0] = x;
-    (*station)[1] = y;
-    (*station)[2] = z;
+    StationBorehole* station = new StationBorehole(x, y, z, name);
     station->_depth = depth;
     if (date != "0000-00-00")
     {
-- 
GitLab