• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

icsm-au / DynAdjust / 5021237816

pending completion
5021237816

Pull #222

github

GitHub
Merge 6e730fa5a into 72bc8feb8
Pull Request #222: Upgrade to C++17 and various enhancements

159 of 159 new or added lines in 7 files covered. (100.0%)

30773 of 38869 relevant lines covered (79.17%)

3959.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.44
/dynadjust/include/measurement_types/dnastation.cpp
1
//============================================================================
2
// Name         : dnastation.cpp
3
// Author       : Roger Fraser
4
// Contributors :
5
// Version      : 1.00
6
// Copyright    : Copyright 2017 Geoscience Australia
7
//
8
//                Licensed under the Apache License, Version 2.0 (the "License");
9
//                you may not use this file except in compliance with the License.
10
//                You may obtain a copy of the License at
11
//               
12
//                http ://www.apache.org/licenses/LICENSE-2.0
13
//               
14
//                Unless required by applicable law or agreed to in writing, software
15
//                distributed under the License is distributed on an "AS IS" BASIS,
16
//                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
//                See the License for the specific language governing permissions and
18
//                limitations under the License.
19
//
20
// Description  : DynAdjust CDnaStation implementation file
21
//============================================================================
22

23
#include <include/measurement_types/dnastation.hpp>
24
#include <include/parameters/dnaepsg.hpp>
25
#include <include/exception/dnaexception.hpp>
26

27
using namespace std;
28
using namespace dynadjust::epsg;
29
using namespace dynadjust::datum_parameters;
30
using namespace dynadjust::exception;
31

32
namespace dynadjust {
33
namespace measurements {
34

35
// Comparison functions
36
// m_strName
37
bool operator<(const CDnaStation& left, const CDnaStation& right)
×
38
{
39
        return left.m_strName < right.m_strName;
×
40
}
41

42
bool operator<(const boost::shared_ptr<CDnaStation>& left, const boost::shared_ptr<CDnaStation>& right)
22,592✔
43
{
44
        return left.get()->m_strName < right.get()->m_strName;
22,592✔
45
}
46

47
CAStationList::CAStationList()
4,910✔
48
        : availMsrCount_ (0)
4,910✔
49
        , assocMsrCount_ (0)
4,910✔
50
        , amlStnIndex_ (0)
4,910✔
51
        , validStation_(VALID_STATION)
4,910✔
52
{
53
}
4,910✔
54

55
CAStationList::CAStationList(bool validStation)
43✔
56
        : availMsrCount_ (0)
43✔
57
        , assocMsrCount_ (0)
43✔
58
        , amlStnIndex_ (0)
43✔
59
        , validStation_(validStation ? VALID_STATION : INVALID_STATION)
43✔
60
{
61
}
43✔
62

63
CAStationList::~CAStationList()
7,834✔
64
{
65

66
}
7,834✔
67

68
// move constructor
69
CAStationList::CAStationList(const CAStationList&& s)
×
70
{
71
        availMsrCount_ = s.availMsrCount_;
×
72
        assocMsrCount_ = s.assocMsrCount_;
×
73
        amlStnIndex_ = s.amlStnIndex_;
×
74
        validStation_ = s.validStation_;
×
75
}
×
76

77

78
// move assignment operator
79
CAStationList& CAStationList::operator =(CAStationList&& rhs)
×
80
{
81
        // check for assignment to self!
82
        if (this == &rhs)
×
83
                return *this;
84

85
        availMsrCount_ = rhs.availMsrCount_;
×
86
        assocMsrCount_ = rhs.assocMsrCount_;
×
87
        amlStnIndex_ = rhs.amlStnIndex_;
×
88
        validStation_ = rhs.validStation_;
×
89

90
        return *this;
×
91
}
92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107
//<CDnaStation>//
108
CDnaStation::CDnaStation(const string& referenceframe, const string& epoch)
3,257✔
109
        : m_strName(""), m_strOriginalName("")
3,257✔
110
        , m_dXAxis(0.), m_dYAxis(0.), m_dZAxis(0.), m_dHeight(0.)
3,257✔
111
        , m_dStdDevX(0.), m_dStdDevY(0.), m_dStdDevZ(0.), m_dStdDevHt(0.)
3,257✔
112
        , m_strConstraints("FFF"), m_strType(""), m_strHemisphereZone(""), m_strDescription(""), m_strComment("")
3,257✔
113
        , m_cLatConstraint('F'), m_cLonConstraint('F'), m_cHtConstraint('F')
3,257✔
114
        , m_ctType(LLH_type_i), m_ctTypeSupplied(LLH_type_i), m_htType(ORTHOMETRIC_type_i)
3,257✔
115
        , m_dcurrentLatitude(0.), m_dcurrentLongitude(0.), m_dcurrentHeight(0.)
3,257✔
116
        , m_fgeoidSep(0.), m_dmeridianDef(0.), m_dverticalDef(0.)
3,257✔
117
        , m_lfileOrder(0), m_lnameOrder(0)
3,257✔
118
        , m_zone(0), m_unusedStation(INVALID_STATION)
3,257✔
119
        , m_referenceFrame(referenceframe), m_epoch(epoch)
3,257✔
120
        , m_constraintType(free_3D)
6,514✔
121
{
122
        m_epsgCode = epsgStringFromName<string>(referenceframe);
3,257✔
123
}
3,257✔
124

125
CDnaStation::~CDnaStation()
4,024✔
126
{
127
}
4,024✔
128

129
// copy constructors
130
CDnaStation::CDnaStation(const CDnaStation& newStation)
6✔
131
{
132
        m_strName = newStation.m_strName;
6✔
133
        m_strOriginalName = newStation.m_strOriginalName;
6✔
134
        m_strConstraints = newStation.m_strConstraints;
6✔
135
        m_strType = newStation.m_strType;
6✔
136
        m_dXAxis = newStation.m_dXAxis;
6✔
137
        m_dYAxis = newStation.m_dYAxis;
6✔
138
        m_dZAxis = newStation.m_dZAxis;
6✔
139
        m_dHeight = newStation.m_dHeight;
6✔
140
        m_dStdDevX = newStation.m_dStdDevX;
6✔
141
        m_dStdDevY = newStation.m_dStdDevY;
6✔
142
        m_dStdDevZ = newStation.m_dStdDevZ;
6✔
143
        m_dStdDevHt = newStation.m_dStdDevHt;
6✔
144
        m_strHemisphereZone = newStation.m_strHemisphereZone;
6✔
145
        m_strDescription = newStation.m_strDescription;
6✔
146
        m_cLatConstraint = newStation.m_cLatConstraint;
6✔
147
        m_cLonConstraint = newStation.m_cLonConstraint;
6✔
148
        m_cHtConstraint = newStation.m_cHtConstraint;
6✔
149
        m_strComment = newStation.m_strComment;
6✔
150

151
        m_ctTypeSupplied = newStation.m_ctTypeSupplied;
6✔
152
        m_ctType = newStation.m_ctType;
6✔
153
        m_htType = newStation.m_htType;
6✔
154

155
        m_dcurrentLatitude = newStation.m_dcurrentLatitude;
6✔
156
        m_dcurrentLongitude = newStation.m_dcurrentLongitude;
6✔
157
        m_dcurrentHeight = newStation.m_dcurrentHeight;
6✔
158
        m_fgeoidSep = newStation.m_fgeoidSep;
6✔
159
        m_dmeridianDef = newStation.m_dmeridianDef;
6✔
160
        m_dverticalDef = newStation.m_dverticalDef;
6✔
161
        m_lfileOrder = newStation.m_lfileOrder;
6✔
162
        m_lnameOrder = newStation.m_lnameOrder;
6✔
163
        m_zone = newStation.m_zone;
6✔
164
        m_unusedStation = newStation.m_unusedStation;
6✔
165

166
        m_referenceFrame = newStation.m_referenceFrame;
6✔
167
        m_epsgCode = newStation.m_epsgCode;
6✔
168
        m_epoch = newStation.m_epoch;
6✔
169

170
        m_constraintType = newStation.m_constraintType;
6✔
171
}
6✔
172

173
CDnaStation::CDnaStation(const string& strName, const string& strConstraints, 
21✔
174
        const string& strType, const double& dXAxis, const double& dYAxis, const double& dZAxis,
175
        const double& dHeight, const string& strHemisphereZone, const string& strDescription, 
176
        const string& strComment)
21✔
177
{
178
        m_strName = strName;
21✔
179

180
        m_strOriginalName = "";
21✔
181
        
182
        SetConstraints(strConstraints);
21✔
183
        SetCoordType(strType);
21✔
184

185
        m_dXAxis = dXAxis;
21✔
186
        m_dYAxis = dYAxis;
21✔
187
        m_dZAxis = dZAxis;
21✔
188
        m_dHeight = dHeight;
21✔
189

190
        m_dStdDevX = PRECISION_1E5;
21✔
191
        m_dStdDevY = PRECISION_1E5;
21✔
192
        m_dStdDevZ = PRECISION_1E5;
21✔
193
        m_dStdDevHt = PRECISION_1E4;
21✔
194

195
        if (strHemisphereZone.empty())
21✔
196
                m_zone = 0;
21✔
197
        else
198
                SetHemisphereZone(strHemisphereZone);
×
199

200
        m_strDescription = strDescription;
21✔
201
        m_strComment = strComment;
21✔
202
        m_unusedStation = INVALID_STATION;
21✔
203

204
        m_dcurrentLatitude = 0.;
21✔
205
        m_dcurrentLongitude = 0.;
21✔
206
        m_dcurrentHeight = 0.;
21✔
207
        m_fgeoidSep = 0.;
21✔
208
        m_dmeridianDef = 0.;
21✔
209
        m_dverticalDef = 0.;
21✔
210

211
        m_referenceFrame = DEFAULT_DATUM;
21✔
212
        m_epsgCode = DEFAULT_EPSG_S;
21✔
213
        m_epoch = "";
21✔
214
}
21✔
215

216
CDnaStation& CDnaStation::operator =(const CDnaStation& rhs)
×
217
{
218
        // check for assignment to self!
219
        if (this == &rhs)
×
220
                return *this;
221

222
        m_strName = rhs.m_strName;
×
223
        m_strConstraints = rhs.m_strConstraints;
×
224
        m_strType = rhs.m_strType;
×
225
        m_dXAxis = rhs.m_dXAxis;
×
226
        m_dYAxis = rhs.m_dYAxis;
×
227
        m_dZAxis = rhs.m_dZAxis;
×
228
        m_dHeight = rhs.m_dHeight;
×
229
        m_strHemisphereZone = rhs.m_strHemisphereZone;
×
230
        m_strDescription = rhs.m_strDescription;
×
231
        m_cLatConstraint = rhs.m_cLatConstraint;
×
232
        m_cLonConstraint = rhs.m_cLonConstraint;
×
233
        m_cHtConstraint = rhs.m_cHtConstraint;
×
234
        m_strComment = rhs.m_strComment;
×
235

236
        m_ctTypeSupplied = rhs.m_ctTypeSupplied;
×
237
        m_ctType = rhs.m_ctType;
×
238
        m_htType = rhs.m_htType;
×
239

240
        // measurement file extras
241
        m_dStdDevX = rhs.m_dStdDevX;
×
242
        m_dStdDevY = rhs.m_dStdDevY;
×
243
        m_dStdDevHt = rhs.m_dStdDevHt;
×
244

245
        m_dcurrentLatitude = rhs.m_dcurrentLatitude;
×
246
        m_dcurrentLongitude = rhs.m_dcurrentLongitude;
×
247
        m_dcurrentHeight = rhs.m_dcurrentHeight;
×
248
        m_fgeoidSep = rhs.m_fgeoidSep;
×
249
        m_dmeridianDef = rhs.m_dmeridianDef;
×
250
        m_dverticalDef = rhs.m_dverticalDef;
×
251
        m_lfileOrder = rhs.m_lfileOrder;
×
252
        m_lnameOrder = rhs.m_lnameOrder;
×
253
        m_zone = rhs.m_zone;
×
254

255
        m_unusedStation = rhs.m_unusedStation;
×
256

257
        m_referenceFrame = rhs.m_referenceFrame;
×
258
        m_epsgCode = rhs.m_epsgCode;
×
259
        m_epoch = rhs.m_epoch;
×
260

261
        m_constraintType = rhs.m_constraintType;
×
262
        
263
        return *this;
×
264
}
265

266

267
void CDnaStation::SetConstraints(const string& sConstraints)
4,141✔
268
{
269
        // capture string, trim whitespace
270
        m_strConstraints = trimstr(sConstraints);
4,141✔
271
        
272
        // No string provided?  Fill with FFF
273
        if (sConstraints.empty())
4,141✔
274
                m_strConstraints = "FFF";
×
275

276
        // Greater than 3 characters?  Trim to 3 characters
277
        if (m_strConstraints.length() > 3)
4,141✔
278
                m_strConstraints = m_strConstraints.substr(0, 3);
×
279
        
280
        // Less than 3 characters?  Pad with 'F'
281
        if (m_strConstraints.length() < 3)
4,141✔
282
                m_strConstraints.append(size_t(3 - m_strConstraints.length()), 'F');
×
283
        
284
        m_cLatConstraint = (char)(*m_strConstraints.substr(0, 1).c_str());
4,141✔
285
        m_cLonConstraint = (char)(*m_strConstraints.substr(1, 1).c_str());
4,141✔
286
        m_cHtConstraint = (char)(*m_strConstraints.substr(2, 1).c_str());
4,141✔
287

288
        // Free in all 3 dimensions
289
        if (iequals(m_strConstraints, "FFF"))
4,141✔
290
                m_constraintType = free_3D;
4,023✔
291
        // Constrained in all 3 dimensions
292
        else if (iequals(m_strConstraints, "CCC"))
118✔
293
                m_constraintType = constrained_3D;
46✔
294
        // Horizontal or 2D adjustment
295
        else if (iequals(m_strConstraints, "FFC"))
72✔
296
                m_constraintType = free_2D;
34✔
297
        // Vertical or 1D adjustment
298
        else if (iequals(m_strConstraints, "CCF"))
38✔
299
                m_constraintType = free_1D;
19✔
300
        else
301
                m_constraintType = custom_constraint;
19✔
302
}
4,141✔
303
        
304

305
void CDnaStation::SetCoordType(const string& sType) {
4,141✔
306
        m_strType = trimstr(sType);
4,141✔
307
        m_ctTypeSupplied = m_ctType = GetMyCoordTypeC();        
4,141✔
308
}
4,141✔
309

310
// X, Easting, Latitude
311
void CDnaStation::SetXAxis(const string& str)
3,116✔
312
{
313
        switch (m_ctType)
3,116✔
314
        {
315
        case LLH_type_i:
608✔
316
        case LLh_type_i:
608✔
317
                FromDmsString(&m_dXAxis, trimstr(str));
608✔
318
                m_dXAxis = Radians(m_dXAxis);
608✔
319
                break;
608✔
320
        default:
2,508✔
321
                // All other types will be converted by dna_import::ReduceStations_LLH()
322
                DoubleFromString(m_dXAxis, trimstr(str));
2,508✔
323
        }
324
}
3,116✔
325

326

327
// Y, Northing, Longitude
328
void CDnaStation::SetYAxis(const string& str)
3,116✔
329
{
330
        switch (m_ctType)
3,116✔
331
        {
332
        case LLH_type_i:
608✔
333
        case LLh_type_i:
608✔
334
                FromDmsString(&m_dYAxis, trimstr(str));
608✔
335
                m_dYAxis = Radians(m_dYAxis);
608✔
336
                break;
608✔
337
        default:
2,508✔
338
                DoubleFromString(m_dYAxis, trimstr(str));
2,508✔
339
        }
340
}
3,116✔
341

342

343
// Z
344
void CDnaStation::SetZAxis(const string& str)
259✔
345
{
346
        DoubleFromString(m_dZAxis, trimstr(str));
259✔
347
}
259✔
348

349

350
// Height
351
void CDnaStation::SetHeight(const string& str)
2,920✔
352
{
353
        if (GetMyCoordTypeC() == XYZ_type_i)
2,920✔
354
                SetZAxis(str);
63✔
355
        else
356
                DoubleFromString(m_dHeight, trimstr(str));
2,857✔
357
}
2,920✔
358

359
// Hemisphere zone
360
void CDnaStation::SetHemisphereZone(const string& sHemisphereZone)
2,901✔
361
{
362
        m_strHemisphereZone = trimstr(sHemisphereZone);
2,901✔
363
        if (m_strHemisphereZone.empty())
2,901✔
364
                return;
365
        if (isdigit(m_strHemisphereZone.substr(0).c_str()[0]))                                        // is the first character a decimal digit?
2,249✔
366
                m_zone = LongFromString<UINT32>(m_strHemisphereZone.substr(0));                // extract zone from first position
2,235✔
367
        else
368
                m_zone = LongFromString<UINT32>(m_strHemisphereZone.substr(1));                // extract zone after hemisphere
14✔
369
}
370

371
// Reduce from Cartesian or Projection to Geographic
372
// m_dXAxis always contains X, Easting and Latitude
373
// m_dYAxis always contains Y, Northing and Longitude
374
void CDnaStation::ReduceStations_LLH(const CDnaEllipsoid* m_eEllipsoid, const CDnaProjection* m_pProjection)
3,140✔
375
{
376
        switch (m_ctType)
3,140✔
377
        {
378
        case XYZ_type_i:
283✔
379
                // Convert from cartesian to geographic (radians)
380
                CartToGeo<double>(m_dXAxis, m_dYAxis, m_dZAxis, &m_dXAxis, &m_dYAxis, &m_dHeight, m_eEllipsoid);
283✔
381
                m_dZAxis= 0.;
283✔
382
                m_htType = ELLIPSOIDAL_type_i;
283✔
383

384
                // Force the current type to be geographic (ellipsoid height).  
385
                // The user-supplied type is retained in m_ctTypeSupplied
386
                m_ctType = LLh_type_i;
283✔
387
                m_strType = LLh_type;
283✔
388
                break;
389
        case UTM_type_i:
2,249✔
390
                // Convert from projection to geographic (radians)
391
                GridToGeo<double, UINT32>(m_dXAxis, m_dYAxis, m_zone, &m_dXAxis, &m_dYAxis, 
2,249✔
392
                        m_eEllipsoid->GetSemiMajor(), m_eEllipsoid->GetInverseFlattening(),                // ellipsoid parameters
2,249✔
393
                        m_pProjection->GetFalseEasting(), m_pProjection->GetFalseNorthing(),        // projection parameters
2,249✔
394
                        m_pProjection->GetCentralScaleFactor(), m_pProjection->GetLongCentralMeridianZone1(), 
2,249✔
395
                        m_pProjection->GetZoneWidth());
2,249✔
396

397
                // Force the current type to be geographic (orthometric height).
398
                // The user-supplied type is retained in m_ctTypeSupplied
399
                m_ctType = LLH_type_i;
2,249✔
400
                m_strType = LLH_type;
2,249✔
401
                break;
402
        default:
403
                break;
404
        }
405
}
3,140✔
406

407
// Reduce from Geographic or Projection to Cartesian
408
// m_dXAxis always contains X, Easting and Latitude
409
// m_dYAxis always contains Y, Northing and Longitude
410
void CDnaStation::ReduceStations_XYZ(const CDnaEllipsoid* m_eEllipsoid, const CDnaProjection* m_pProjection)
3✔
411
{
412
        switch (m_ctType)
3✔
413
        {
414
        case UTM_type_i:
×
415
                // Convert from projection to geographic (radians)
416
                GridToGeo<double, UINT32>(m_dXAxis, m_dYAxis, m_zone, &m_dXAxis, &m_dYAxis, 
×
417
                        m_eEllipsoid->GetSemiMajor(), m_eEllipsoid->GetInverseFlattening(),        // ellipsoid parameters
×
418
                        m_pProjection->GetFalseEasting(), m_pProjection->GetFalseNorthing(),        // projection parameters
×
419
                        m_pProjection->GetCentralScaleFactor(), m_pProjection->GetLongCentralMeridianZone1(), 
×
420
                        m_pProjection->GetZoneWidth());
×
421
                [[fallthrough]];
3✔
422
        case LLH_type_i:
3✔
423
        case LLh_type_i:
3✔
424
                m_dcurrentLatitude = m_dXAxis;
3✔
425
                m_dcurrentLongitude = m_dYAxis;
3✔
426
                m_dcurrentHeight = m_dHeight;
3✔
427
                if (m_ctType == LLH_type_i)
3✔
428
                        m_dcurrentHeight += m_fgeoidSep;
3✔
429
                // Convert from geographic (radians) to cartesian
430
                // Assumes height is ellipsoidal
431
                GeoToCart<double>(m_dcurrentLatitude, m_dcurrentLongitude, m_dcurrentHeight, &m_dXAxis, &m_dYAxis, &m_dZAxis, m_eEllipsoid);
3✔
432
                break;
3✔
433
        default:
434
                break;
435
        }
436

437
        // Force the current type to be geographic.  The user-supplied type is retained in m_ctTypeSupplied
438
        m_ctType = XYZ_type_i;
3✔
439
        m_strType = XYZ_type;
3✔
440
}
3✔
441

442
bool CDnaStation::IsValidConstraint(const string& sConst)
4✔
443
{
444
        if (iequals(sConst, "CCC"))
4✔
445
                return true;
446
        if (iequals(sConst, "CCF"))
1✔
447
                return true;
448
        if (iequals(sConst, "CFF"))
1✔
449
                return true;
450
        if (iequals(sConst, "FFF"))
1✔
451
                return true;
452
        if (iequals(sConst, "FFC"))
1✔
453
                return true;
454
        if (iequals(sConst, "FCC"))
1✔
455
                return true;
456
        if (iequals(sConst, "FCF"))
1✔
457
                return true;
458
        if (iequals(sConst, "CFC"))
1✔
459
                return true;
×
460
        return false;
461
}
462
        
463

464
_COORD_TYPE_ CDnaStation::GetCoordTypeC(const string& sType)
10,458✔
465
{
466
        // case insensitive
467
        if (iequals(sType, XYZ_type))
10,458✔
468
                return XYZ_type_i;
469
        else if (iequals(sType, UTM_type))
8,531✔
470
                return UTM_type_i;                                // height is assumed to be orthometric
471
        else if (iequals(sType, ENU_type))
2,841✔
472
                return ENU_type_i;
473

474
        // case sensitive
475
        else if (boost::equals(sType, LLh_type))
2,841✔
476
                return LLh_type_i;                                // ellipsoid height
477
        
478
        // default
479
        else if (boost::equals(sType, LLH_type))
2,702✔
480
                return LLH_type_i;                                        // orthometric height (default)
481

482
        // If this point is reached, sType is an unknown coordinate type, so throw!
483
        stringstream ss;
×
484
        ss << "  '" << sType << "' is not a recognised coordinate type." << endl;
×
485
        throw boost::enable_current_exception(runtime_error(ss.str()));
×
486

487
        return LLH_type_i;
488
}
×
489

490

491
_COORD_TYPE_ CDnaStation::GetMyCoordTypeC() const
8,905✔
492
{
493
        return GetCoordTypeC(m_strType);
8,905✔
494
}
495

496

497
_HEIGHT_SYSTEM_ CDnaStation::GetHeightSystemC(const string& sType) const
×
498
{
499
        if (sType.compare(ELLIPSOIDAL_type) == 0)
×
500
                return ELLIPSOIDAL_type_i;
×
501
        return ORTHOMETRIC_type_i;                // default
502
}
503

504

505
_HEIGHT_SYSTEM_ CDnaStation::GetMyHeightSystemC() const
×
506
{
507
        if (m_strType.compare(LLh_type) == 0)
×
508
                return ELLIPSOIDAL_type_i;
×
509
        return ORTHOMETRIC_type_i;        // default
510
}
511

512
// SetHeightSystem called by void Height_pimpl::system(const ::std::string& system)
513
// where system is an attribute of the element Height (either "ellipsoidal" or "orthometric")
514
void CDnaStation::SetHeightSystem(const string& sType)
×
515
{
516
        SetHeightSystem(GetHeightSystemC(sType));
×
517
}
×
518
        
519
void CDnaStation::SetHeightSystem(const HEIGHT_SYSTEM& type_i)
×
520
{
521
        m_htType = type_i;
×
522

523
        switch (m_htType)
×
524
        {
525
        case ELLIPSOIDAL_type_i:
×
526
                // Convert to orthometric
527
                if (m_ctType == LLH_type_i)
×
528
                        m_ctType = LLh_type_i;
×
529
                if (m_strType.compare(LLH_type))
×
530
                        m_strType = LLh_type;
×
531
                break;
532
        case ORTHOMETRIC_type_i:
×
533
                // Convert to ellipsoidal
534
                if (m_ctType == LLh_type_i)
×
535
                        m_ctType = LLH_type_i;
×
536
                if (m_strType.compare(LLh_type))
×
537
                        m_strType = LLH_type;
×
538
                break;
539
        }
540
}
×
541

542
//void CDnaStation::coutStationData(ostream &os, ostream &os2, const UINT16& uType) const
543
//{
544
//        UINT32 precision = 3;
545
//        if (m_ctType == LLH_type_i)
546
//                precision = 10;
547
//        stringstream ss;
548
//        string str;
549
//        size_t dot;
550
//
551
//        switch (uType)
552
//        {
553
//        case DNA_COUT:
554
//        case GEOLAB_COUT:
555
//                
556
//                os << "+ " << setw(16) << m_strName;
557
//                os << setw(4) << m_strConstraints;
558
//                os << setw(4) << m_strType;
559
//                os << setw(20) << setprecision(precision) << fixed << (m_ctType == LLH_type_i ? RadtoDms(m_dXAxis): m_dXAxis);
560
//                os << setw(20) << setprecision(precision) << fixed << (m_ctType == LLH_type_i ? RadtoDmsL(m_dYAxis): m_dYAxis);
561
//                //os << setw(16) << vStations[s].GetZAxis();
562
//                os << setw(13) << setprecision(4) << fixed << m_dHeight;
563
//                //os << setw(10) << vStations[s].GetRedHeight();
564
//                os << setw(5) << m_strHemisphereZone;
565
//                os << setw(6) << m_lnameOrder;
566
//                os << setw(19) << m_strDescription;
567
//                //os << setw(10) << vStations[s].GetComment();
568
//                os << endl;
569
//                break;
570
//        case NEWGAN_COUT:
571
//                os << setw(3) << "4";
572
//                os << right << setw(12) << m_strName;
573
//                os << " ";
574
//                os << left << setw(23) << m_strDescription.substr(0, 23);
575
//                ss.str("");
576
//                ss << setprecision(precision) << fixed << (m_ctType == LLH_type_i ? RadtoDms(m_dXAxis): m_dXAxis);
577
//                str = trimstr(ss.str());
578
//                dot = str.find(".");
579
//                str.replace(dot, 1, " ");
580
//                str.insert(dot+5, ".");
581
//                if (m_dXAxis < 0)
582
//                {
583
//                        str.replace(0, 1, " ");                // replace negative sign
584
//                        str = trimstr(str);
585
//                        os << left << "S" << setw(precision + 4) << right << str;
586
//                }
587
//                else
588
//                        os << left << "N" << setw(precision + 4) << right << str;
589
//                
590
//                ss.str("");
591
//                ss << setprecision(precision) << fixed << (m_ctType == LLH_type_i ? RadtoDmsL(m_dYAxis): m_dYAxis);
592
//                str = trimstr(ss.str());
593
//                dot = str.find(".");
594
//                str.replace(dot, 1, " ");
595
//                str.insert(dot+5, ".");
596
//                if (m_dYAxis < 0)
597
//                {
598
//                        str.replace(0, 1, " ");                // replace negative sign
599
//                        str = trimstr(str);
600
//                        os << left << "W" << setw(precision + 5) << right << str;
601
//                }
602
//                else
603
//                        os << left << "E" << setw(precision + 5) << right << str;
604
//                
605
//                
606
//                os << right << setw(9) << setprecision(3) << fixed << m_dHeight;
607
//                os << endl;
608
//                break;
609
//        case GMT_OUT:
610
//                os << setprecision(precision) << fixed << (m_ctType == LLH_type_i ? DegreesL(m_dYAxis): m_dYAxis);
611
//                os << "  ";
612
//                os << setprecision(precision) << fixed << (m_ctType == LLH_type_i ? Degrees(m_dXAxis): m_dXAxis);
613
//                os << endl;
614
//
615
//                os2 << setprecision(precision) << fixed << (m_ctType == LLH_type_i ? DegreesL(m_dYAxis): m_dYAxis);
616
//                os2 << "  ";
617
//                os2 << setprecision(precision) << fixed << (m_ctType == LLH_type_i ? Degrees(m_dXAxis): m_dXAxis);
618
//                os2 << "  6 0 0 LM " << m_strName << endl;                
619
//                break;
620
//        }
621
//        
622
//
623
//}
624

625

626
void CDnaStation::WriteBinaryStn(std::ofstream* binary_stream, const UINT16 bUnused)
2,881✔
627
{
628
        station_t stationRecord;
2,881✔
629
        strcpy(stationRecord.stationName, m_strName.substr(0, STN_NAME_WIDTH).c_str());
2,881✔
630
        strcpy(stationRecord.stationNameOrig, m_strOriginalName.substr(0, STN_NAME_WIDTH).c_str());
2,881✔
631
        strcpy(stationRecord.stationConst, m_strConstraints.substr(0, STN_CONST_WIDTH).c_str());
2,881✔
632
        strcpy(stationRecord.stationType, m_strType.substr(0, STN_TYPE_WIDTH).c_str());
2,881✔
633

634
        stationRecord.suppliedStationType = m_ctTypeSupplied;
2,881✔
635

636
        switch (m_ctTypeSupplied)
2,881✔
637
        {
638
        case LLH_type_i:
2,603✔
639
        case UTM_type_i:
2,603✔
640
                stationRecord.suppliedHeightRefFrame = ORTHOMETRIC_type_i;
2,603✔
641
                break;
2,603✔
642
        default:
643
                break;
644
        }
645

646
        stationRecord.initialLatitude = m_dXAxis;
2,881✔
647
        if (fabs(m_dcurrentLatitude - 0.) < PRECISION_1E15)
2,881✔
648
                stationRecord.currentLatitude = m_dXAxis;
2,758✔
649
        else
650
                stationRecord.currentLatitude = m_dcurrentLatitude;
123✔
651
        
652
        stationRecord.initialLongitude = m_dYAxis;
2,881✔
653
        if (fabs(m_dcurrentLongitude - 0.) < PRECISION_1E15)
2,881✔
654
                stationRecord.currentLongitude = m_dYAxis;
2,758✔
655
        else
656
                stationRecord.currentLongitude = m_dcurrentLongitude;
123✔
657

658
        stationRecord.initialHeight = m_dHeight;        
2,881✔
659
        if (fabs(m_dcurrentHeight - 0.) < PRECISION_1E15)
2,881✔
660
                stationRecord.currentHeight = m_dHeight;
2,609✔
661
        else
662
                stationRecord.currentHeight = m_dcurrentHeight;
272✔
663
                
664
        stationRecord.geoidSep = m_fgeoidSep;
2,881✔
665
        stationRecord.meridianDef = m_dmeridianDef;
2,881✔
666
        stationRecord.verticalDef = m_dverticalDef;
2,881✔
667
        stationRecord.zone = m_zone;
2,881✔
668
        strcpy(stationRecord.description, m_strDescription.substr(0, STN_DESC_WIDTH).c_str());
2,881✔
669
        stationRecord.fileOrder = m_lfileOrder;
2,881✔
670
        stationRecord.nameOrder = m_lnameOrder;
2,881✔
671
        stationRecord.unusedStation = bUnused;
2,881✔
672

673
        strcpy(stationRecord.epoch, m_epoch.substr(0, STN_EPOCH_WIDTH).c_str());
2,881✔
674
        strcpy(stationRecord.epsgCode, m_epsgCode.substr(0, STN_EPSG_WIDTH).c_str());
2,881✔
675

676
        binary_stream->write(reinterpret_cast<char *>(&stationRecord), sizeof(station_t));
2,881✔
677
}
2,881✔
678

679

680
void CDnaStation::WriteDNAXMLStnCurrentEstimates(std::ofstream* dna_ofstream, 
883✔
681
        const CDnaEllipsoid* ellipsoid, const CDnaProjection* projection,
682
        INPUT_FILE_TYPE t, const dna_stn_fields* dsw)
683
{
684
        // Get the latest estimates
685
        double lat_east_x(m_dcurrentLatitude);
883✔
686
        double lon_north_y(m_dcurrentLongitude);
883✔
687
        double ht_zone_z(m_dcurrentHeight);
883✔
688

689
        // Write latest station estimates
690
        WriteDNAXMLStn(dna_ofstream,
883✔
691
                ellipsoid, projection,
692
                lat_east_x, lon_north_y, ht_zone_z,
693
                t, dsw);
694
}
883✔
695
        
696

697
void CDnaStation::WriteDNAXMLStnInitialEstimates(std::ofstream* dna_ofstream, 
584✔
698
        const CDnaEllipsoid* ellipsoid, const CDnaProjection* projection,
699
        INPUT_FILE_TYPE t, const dna_stn_fields* dsw)
700
{
701
        // Write initial station estimates
702
        WriteDNAXMLStn(dna_ofstream,
584✔
703
                ellipsoid, projection,
704
                m_dXAxis, m_dYAxis, m_dHeight,
584✔
705
                t, dsw);
706
}
584✔
707

708

709
void CDnaStation::WriteDNAXMLStn(std::ofstream* dna_ofstream,
1,467✔
710
        const CDnaEllipsoid* ellipsoid, const CDnaProjection* projection,
711
        const double& lat_east_x, const double& lon_north_y, const double& ht_zone_z,
712
        INPUT_FILE_TYPE t, const dna_stn_fields* dsw)
713
{
714
        //m_ctTypeSupplied = LLh_type_i;
715

716
        string hemisphereZone(m_strHemisphereZone);
1,467✔
717
        string coordinateType(LLH_type);
1,467✔
718

719
        switch (m_ctTypeSupplied)
1,467✔
720
        {
721
        case XYZ_type_i:
179✔
722
                coordinateType = XYZ_type;
179✔
723
                break;
724
        case LLh_type_i:
×
725
                coordinateType = LLh_type;
×
726
                break;
727
        case UTM_type_i:
894✔
728
                coordinateType = UTM_type;
894✔
729
                break;
730
        case ENU_type_i:        // Not supported yet, so revert to Lat, Long, Height
×
731
                coordinateType = LLH_type;
×
732
                m_ctTypeSupplied = LLH_type_i;
×
733
                break;
×
734
        case LLH_type_i:
394✔
735
                coordinateType = LLH_type;
394✔
736
                break;
737
        default:
738
                break;
739
        }
740

741
        // Convert height to orthometric?
742
        // Decisions for printing (estimated) station height for various input coordinate types
743
        // and geoid model.  Estimated stations are in LLh.
744
        // h = H + Na
745
        //
746
        // Input Coord type                Geoid loaded?          Geoid not loaded?          Result
747
        // ---------------------------------------------------------------------------------
748
        // LLH                                    ht_z - m_fgeoidSep     ht_z (m_fgeoidSep = 0)     H (orthometric)
749
        // UTM                                        ht_z - m_fgeoidSep     ht_z (m_fgeoidSep = 0)     H (orthometric)
750
        // ENU                                        ht_z - m_fgeoidSep     ht_z (m_fgeoidSep = 0)     H (orthometric)
751
        // LLh                      ht_z                               ht_z                                              h (ellipsoid)
752
        // XYZ                      LLh->XYZ                       LLh->XYZ                                          X, Y, Z
753
        double lat_east_x_mod(lat_east_x);
1,467✔
754
        double lon_north_y_mod(lon_north_y);
1,467✔
755
        double ht_zone_z_mod(ht_zone_z);
1,467✔
756

757
        switch (m_ctTypeSupplied)
1,467✔
758
        {
759
        case LLH_type_i:
1,288✔
760
        case UTM_type_i:
1,288✔
761
                // reduce to orthometric.  
762
                // If geoid hasn't been loaded, m_fgeoidSep will be 0.0
763
                ht_zone_z_mod -= m_fgeoidSep;
1,288✔
764
                break;
1,288✔
765
        default:
766
                break;
767
        }
768

769
        // Convert coordinates to cartesian or utm?
770
        // Convert radians values to degrees, minutes and seconds?
771
        stringstream ss;
2,934✔
772
        double zone;
1,467✔
773
        switch (m_ctTypeSupplied)
1,467✔
774
        {
775
        case XYZ_type_i:
179✔
776
                GeoToCart<double>(lat_east_x, lon_north_y, ht_zone_z, 
179✔
777
                        &lat_east_x_mod, &lon_north_y_mod, &ht_zone_z_mod, ellipsoid);
778
                break;
779
        
780
        case UTM_type_i:
894✔
781
                GeoToGrid<double>(lat_east_x, lon_north_y, 
894✔
782
                        &lat_east_x_mod, &lon_north_y_mod, &zone, ellipsoid, projection, true);
783
                
784
                ss << fixed << setprecision(0) << zone;
894✔
785
                hemisphereZone = ss.str();        
894✔
786
                break;
894✔
787

788
        case LLh_type_i:
394✔
789
        case LLH_type_i:
394✔
790
                lat_east_x_mod = RadtoDms(lat_east_x);
394✔
791
                lon_north_y_mod = RadtoDmsL(lon_north_y);
394✔
792
                break;
394✔
793
        default:
794
                break;
795
        }
796

797
        switch (t)
1,467✔
798
        {
799
        case dna:
701✔
800
        
801
                // Write DNA station file
802
                WriteDNAStn(dna_ofstream, coordinateType,
701✔
803
                        lat_east_x_mod, lon_north_y_mod, ht_zone_z_mod, 
804
                        hemisphereZone, *dsw);
805
                break;
806

807
        case dynaml:
766✔
808

809
                // Write DynAdjust XML station file
810
                WriteDynaMLStn(dna_ofstream, coordinateType,
766✔
811
                        lat_east_x_mod, lon_north_y_mod, ht_zone_z_mod,
812
                        hemisphereZone);
813
                break;
814
        default:
815
                break;
816
        }
817
}
1,467✔
818

819
void CDnaStation::WriteDNAStn(std::ofstream* dna_ofstream, const string& coordinateType, 
701✔
820
        const double& lat_east_x, const double& lon_north_y, const double& ht_zone_z,
821
        string& hemisphereZone, const dna_stn_fields& dsw)
822
{        
823
        UINT32 LEX_precision(4), LNY_precision(4), HZ_precision(4);        
701✔
824
        
825
        switch (m_ctTypeSupplied)
701✔
826
        {
827
        case LLh_type_i:
142✔
828
        case LLH_type_i:
142✔
829
                LEX_precision = LNY_precision = 10;
142✔
830
                break;
142✔
831
        default:
832
                break;
833
        }
834

835
        (*dna_ofstream) << left << setw(dsw.stn_name) << m_strName;
701✔
836
        (*dna_ofstream) << left << setw(dsw.stn_const) << m_strConstraints;
701✔
837
        (*dna_ofstream) << " ";
701✔
838
        (*dna_ofstream) << left << setw(dsw.stn_type) << coordinateType;
701✔
839
        (*dna_ofstream) << right << setw(dsw.stn_e_phi_x) << setprecision(LEX_precision) << fixed << lat_east_x;
701✔
840
        (*dna_ofstream) << right << setw(dsw.stn_n_lam_y) << setprecision(LNY_precision) << fixed << lon_north_y;
701✔
841
        (*dna_ofstream) << right << setw(dsw.stn_ht_z) << setprecision(HZ_precision) << fixed << ht_zone_z;        
701✔
842
        if (m_ctTypeSupplied == UTM_type_i)
701✔
843
                (*dna_ofstream) << right << setw(dsw.stn_hemi_zo) << hemisphereZone;
447✔
844
        else
845
                (*dna_ofstream) << right << setw(dsw.stn_hemi_zo) << " ";
254✔
846
        (*dna_ofstream) << " ";
701✔
847
        (*dna_ofstream) << left << m_strDescription << endl;
701✔
848
}
701✔
849
        
850

851
void CDnaStation::WriteDynaMLStn(std::ofstream* xml_ofstream, const string& coordinateType, 
766✔
852
        const double& lat_east_x, const double& lon_north_y, const double& ht_zone_z,
853
        string& hemisphereZone)
854
{
855
        UINT32 LEX_precision(4), LNY_precision(4), HZ_precision(4);
766✔
856
        
857
        // Convert radians values to degrees, minutes and seconds
858
        switch (m_ctTypeSupplied)
766✔
859
        {
860
        case LLh_type_i:
252✔
861
        case LLH_type_i:
252✔
862
                LEX_precision = LNY_precision = 10;
252✔
863
                break;
252✔
864
        default:
865
                break;
866
        }
867
        
868
        (*xml_ofstream) << "  <DnaStation>" << endl;
766✔
869
        (*xml_ofstream) << "    <Name>" << m_strName << "</Name>" << endl;
766✔
870
        (*xml_ofstream) << "    <Constraints>" << m_strConstraints << "</Constraints>" << endl;
766✔
871
        (*xml_ofstream) << "    <Type>" << coordinateType << "</Type>" << endl;
766✔
872
        (*xml_ofstream) << "    <StationCoord>" << endl;
766✔
873
        (*xml_ofstream) << "      <Name>" << m_strName << "</Name>" << endl;
766✔
874
        (*xml_ofstream) << "      <XAxis>" << setprecision(LEX_precision) << fixed << lat_east_x << "</XAxis>" << endl;
766✔
875
        (*xml_ofstream) << "      <YAxis>" << setprecision(LNY_precision) << fixed << lon_north_y << "</YAxis>" << endl;
766✔
876
        (*xml_ofstream) << "      <Height>" << setprecision(HZ_precision) << fixed << ht_zone_z << "</Height>" << endl;
766✔
877
        
878
        // Convert radians values to degrees, minutes and seconds
879
        if (m_ctTypeSupplied == UTM_type_i)
766✔
880
                (*xml_ofstream) << "      <HemisphereZone>" << hemisphereZone << "</HemisphereZone>" << endl;
447✔
881
        
882
        (*xml_ofstream) << "    </StationCoord>" << endl;
766✔
883
        (*xml_ofstream) << "    <Description>"  << m_strDescription << "</Description>" << endl;
766✔
884
        (*xml_ofstream) << "  </DnaStation>" << endl;
766✔
885
}
766✔
886
        
887

888
void CDnaStation::WriteGeoidfile(std::ofstream* geo_ofstream)
×
889
{
890
        (*geo_ofstream) << setw(44) << left << m_strName <<
×
891
                setw(15) << setprecision(3) << fixed << left << m_fgeoidSep <<
×
892
                setw(10) << setprecision(3) << fixed << right << m_dmeridianDef <<
×
893
                setw(10) << setprecision(3) << fixed << right << m_dverticalDef << endl;
×
894
}
×
895
        
896

897
void CDnaStation::SetStationRec(const station_t& stationRecord)
1,004✔
898
{
899
        SetName(stationRecord.stationName);
1,004✔
900
        SetOriginalName(stationRecord.stationNameOrig);
1,004✔
901
        SetConstraints(stationRecord.stationConst);
1,004✔
902
        SetCoordType(stationRecord.stationType);
1,004✔
903
        
904
        switch (stationRecord.suppliedStationType)
1,004✔
905
        {
906
        case UTM_type_i:
669✔
907
                m_ctTypeSupplied = UTM_type_i;
669✔
908
                break;
669✔
909
        case XYZ_type_i:
127✔
910
                m_ctTypeSupplied = XYZ_type_i;
127✔
911
                break;
127✔
912
        case ENU_type_i:
×
913
                m_ctTypeSupplied = ENU_type_i;
×
914
                break;
×
915
        case LLh_type_i:
×
916
                m_ctTypeSupplied = LLh_type_i;
×
917
                break;
×
918
        default:
208✔
919
        case LLH_type_i:
208✔
920
                m_ctTypeSupplied = LLH_type_i;
208✔
921
                break;
208✔
922
        }
923
        
924
        m_dXAxis = stationRecord.initialLatitude;
1,004✔
925
        m_dYAxis = stationRecord.initialLongitude;
1,004✔
926
        m_dHeight = stationRecord.initialHeight;
1,004✔
927
        m_dcurrentLatitude = stationRecord.currentLatitude;
1,004✔
928
        m_dcurrentLongitude = stationRecord.currentLongitude;
1,004✔
929
        m_dcurrentHeight = stationRecord.currentHeight;
1,004✔
930
        m_fgeoidSep = stationRecord.geoidSep;
1,004✔
931
        m_dmeridianDef = stationRecord.meridianDef;
1,004✔
932
        m_dverticalDef = stationRecord.verticalDef;
1,004✔
933
        m_zone = stationRecord.zone;
1,004✔
934
        if (stationRecord.initialLatitude < 0.)
1,004✔
935
                m_strHemisphereZone = "S";
971✔
936
        else
937
                m_strHemisphereZone = "N";
33✔
938
        char zone[3];
1,004✔
939
        sprintf(zone, "%d", m_zone);
1,004✔
940
        m_strHemisphereZone += zone;
1,004✔
941
        SetDescription(stationRecord.description);
1,004✔
942
        m_lfileOrder = stationRecord.fileOrder;
1,004✔
943
        m_lnameOrder = stationRecord.nameOrder;
1,004✔
944
        m_unusedStation = (stationRecord.unusedStation == VALID_STATION ? true : false);
1,004✔
945

946
        m_epoch = stationRecord.epoch;
1,004✔
947
        m_epsgCode = stationRecord.epsgCode;
1,004✔
948
        m_referenceFrame = datumFromEpsgCode<string, UINT32>(LongFromString<UINT32>(m_epsgCode));
1,004✔
949
}
1,004✔
950

951
string CDnaStation::CoordinateName(const char& c)
463✔
952
{
953
        switch (c)
463✔
954
        {
955
        case 'P':
71✔
956
                return "Latitude";
71✔
957
        case 'L':
71✔
958
                return "Longitude";
71✔
959
        case 'H':
63✔
960
                return "H(Ortho)";
63✔
961
        case 'h':
63✔
962
                return "h(Ellipse)";
63✔
963
        case 'E':
4✔
964
                return "Easting";
4✔
965
        case 'N':
4✔
966
                return "Northing";
4✔
967
        case 'z':
4✔
968
                return "Zone";
4✔
969
        case 'X':
61✔
970
                return "X";
61✔
971
        case 'Y':
61✔
972
                return "Y";
61✔
973
        case 'Z':
61✔
974
                return "Z";
61✔
975
        }
976
        return "";
×
977
}
978

979
}        // namespace measurements
980
}        // namespace dynadjust
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc