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

icsm-au / DynAdjust / 13494567994

24 Feb 2025 09:15AM UTC coverage: 81.168% (+2.0%) from 79.161%
13494567994

push

github

web-flow
Merge pull request #234 from icsm-au/1.2.8

Version 1.2.8 (fixes, ehnacements, improved datum management)

6131 of 8137 new or added lines in 90 files covered. (75.35%)

162 existing lines in 33 files now uncovered.

32214 of 39688 relevant lines covered (81.17%)

11775.25 hits per line

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

92.86
/dynadjust/include/measurement_types/dnadirection.cpp
1
//============================================================================
2
// Name         : dnadirection.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  : CDnaDirection implementation file
21
//============================================================================
22

23
#include <include/exception/dnaexception.hpp>
24
#include <include/measurement_types/dnadirection.hpp>
25

26
using namespace dynadjust::exception;
27

28
namespace dynadjust {
29
namespace measurements {
30

31
CDnaDirection::CDnaDirection(void)
12,921✔
32
        : m_strTarget("")
25,842✔
33
        , m_drValue(0.)
12,921✔
34
        , m_dStdDev(0.)
12,921✔
35
        , m_fInstHeight(0.)
12,921✔
36
        , m_fTargHeight(0.)
12,921✔
37
        , m_lRecordedTotal(0)
12,921✔
38
        , m_lsetID(0)
12,921✔
39
{
40
        m_strType = "D";
12,921✔
41
        m_MSmeasurementStations = TWO_STATION;
12,921✔
42
}
12,921✔
43

44
CDnaDirection::~CDnaDirection(void)
21,699✔
45
{
46
}
32,946✔
47

48
// move constructor
49
CDnaDirection::CDnaDirection(CDnaDirection&& d)
546✔
50
{
51
        m_strFirst = d.m_strFirst;
546✔
52
        m_bIgnore = d.m_bIgnore;
546✔
53
        m_bInsufficient = d.m_bInsufficient;
546✔
54
        m_strTarget = d.m_strTarget;
546✔
55
        m_drValue = d.m_drValue;
546✔
56
        m_dStdDev = d.m_dStdDev;
546✔
57
        m_fInstHeight = d.m_fInstHeight;
546✔
58
        m_fTargHeight = d.m_fTargHeight;
546✔
59
        m_lRecordedTotal = d.m_lRecordedTotal;
546✔
60
        m_lsetID = d.m_lsetID;
546✔
61
        m_MSmeasurementStations = d.m_MSmeasurementStations;
546✔
62

63
        m_strType = "D";
546✔
64

65
        m_msr_db_map = d.m_msr_db_map;
546✔
66

67
        m_epoch = d.m_epoch;
546✔
68
}
546✔
69

70
// move assignment operator 
71
CDnaDirection& CDnaDirection::operator= (CDnaDirection&& rhs)
×
72
{
73
        // check for assignment to self!
74
        if (this == &rhs)
×
75
                return *this;
76

77
        CDnaMeasurement::operator=(std::move(rhs));
×
78
        m_bInsufficient = rhs.m_bInsufficient;
×
79
        m_strTarget = rhs.m_strTarget;
×
80
        m_drValue = rhs.m_drValue;
×
81
        m_dStdDev = rhs.m_dStdDev;
×
82
        m_fInstHeight = rhs.m_fInstHeight;
×
83
        m_fTargHeight = rhs.m_fTargHeight;
×
84
        m_lRecordedTotal = rhs.m_lRecordedTotal;
×
85
        m_lsetID = rhs.m_lsetID;
×
86
        m_MSmeasurementStations = rhs.m_MSmeasurementStations;
×
87

88
        m_msr_db_map = rhs.m_msr_db_map;
×
89

90
        return *this;
×
91
}
92

93

94

95

96

97

98
//// copy constructor (disabled)
99
//CDnaDirection::CDnaDirection(const CDnaDirection& newDirection)
100
//{
101
//        m_strFirst = newDirection.m_strFirst;
102
//        m_bIgnore = newDirection.m_bIgnore;
103
//        m_strTarget = newDirection.m_strTarget;
104
//        m_drValue = newDirection.m_drValue;
105
//        m_dStdDev = newDirection.m_dStdDev;
106
//        m_fInstHeight = newDirection.m_fInstHeight;
107
//        m_fTargHeight = newDirection.m_fTargHeight;
108
//        m_lRecordedTotal = newDirection.m_lRecordedTotal;
109
//        m_lsetID = newDirection.m_lsetID;
110
//        m_MSmeasurementStations = newDirection.m_MSmeasurementStations;
111
//
112
//        m_strType = "D";
113
//
114
//        m_msr_db_map = newDirection.m_msr_db_map;
115
//}
116

117

118
//CDnaDirection::CDnaDirection(const bool bIgnore, const std::string& strFirst, const std::string& strTarget, const double& drValue, const double& dStdDev)
119
//{
120
//        m_strType = "D";
121
//        m_strFirst = strFirst;
122
//        m_bIgnore = bIgnore;
123
//        m_strTarget = strTarget;
124
//        m_drValue = drValue;
125
//        m_dStdDev = dStdDev;
126
//        m_lRecordedTotal = 0;
127
//        m_lsetID = 0;
128
//}
129

130
// assignment operator (disabled)
131
//CDnaDirection& CDnaDirection::operator= (const CDnaDirection& rhs)
132
//{
133
//        // check for assignment to self!
134
//        if (this == &rhs)
135
//                return *this;
136
//
137
//        CDnaMeasurement::operator=(rhs);
138
//        m_strTarget = rhs.m_strTarget;
139
//        m_drValue = rhs.m_drValue;
140
//        m_dStdDev = rhs.m_dStdDev;
141
//        m_fInstHeight = rhs.m_fInstHeight;
142
//        m_fTargHeight = rhs.m_fTargHeight;
143
//        m_lRecordedTotal = rhs.m_lRecordedTotal;
144
//        m_lsetID = rhs.m_lsetID;
145
//        m_MSmeasurementStations = rhs.m_MSmeasurementStations;
146
//
147
//        m_msr_db_map = rhs.m_msr_db_map;
148
//
149
//        return *this;
150
//}
151

152

153
bool CDnaDirection::operator== (const CDnaDirection& rhs) const
306✔
154
{
155
        return (
306✔
156
                m_strFirst == rhs.m_strFirst &&
511✔
157
                m_bIgnore == rhs.m_bIgnore &&
205✔
158
                m_strTarget == rhs.m_strTarget &&
205✔
159
                m_drValue == rhs.m_drValue &&
39✔
160
                m_dStdDev == rhs.m_dStdDev &&
8✔
161
                m_strType == rhs.m_strType &&
8✔
162
                m_fInstHeight == rhs.m_fInstHeight &&
8✔
163
                m_fTargHeight == rhs.m_fTargHeight &&
314✔
164
                m_epoch == rhs.m_epoch
8✔
165
                );
306✔
166
}
167

168

169
bool CDnaDirection::operator< (const CDnaDirection& rhs) const
2,714✔
170
{
171
        if (m_strFirst == rhs.m_strFirst) {
2,714✔
172
                if (m_strType == rhs.m_strType) {        // could be B, D, V, Z
431✔
173
                        if (m_bIgnore == rhs.m_bIgnore) {
431✔
174
                                if (m_epoch == rhs.m_epoch) {
431✔
175
                                        if (m_strTarget == rhs.m_strTarget) {
431✔
176
                                                if (m_drValue == rhs.m_drValue) {
66✔
177
                                                        if (m_dStdDev == rhs.m_dStdDev) {
27✔
178
                                                                if (m_fInstHeight == rhs.m_fInstHeight)
27✔
179
                                                                        return m_fTargHeight < rhs.m_fTargHeight;
27✔
180
                                                                else
181
                                                                        return m_fInstHeight < rhs.m_fInstHeight; }
×
182
                                                        else
183
                                                                return m_dStdDev < rhs.m_dStdDev; }
×
184
                                                else
185
                                                        return m_drValue < rhs.m_drValue; }
39✔
186
                                        else
187
                                                return m_strTarget < rhs.m_strTarget; }
365✔
188
                                else
189
                                        return m_epoch < rhs.m_epoch; }
×
190
                        else
191
                                return m_bIgnore < rhs.m_bIgnore; }
×
192
                else
193
                        return m_strType < rhs.m_strType; }
×
194
        else
195
                return m_strFirst < rhs.m_strFirst;
2,283✔
196
}
197
        
198

199
void CDnaDirection::WriteDynaMLMsr(std::ofstream* dynaml_stream, const std::string& comment, bool bSubMeasurement /*= false*/) const
466✔
200
{
201
        if (bSubMeasurement)
466✔
202
        {
203
                // Direction set
204
                *dynaml_stream << "    <Directions>" << std::endl;
107✔
205
                if (m_bIgnore)
107✔
206
                        *dynaml_stream << "      <Ignore>*</Ignore>" << std::endl;
6✔
207
                else
208
                        *dynaml_stream << "      <Ignore/>" << std::endl;
101✔
209
                *dynaml_stream << "      <Target>" << m_strTarget << "</Target>" << std::endl;
107✔
210
                *dynaml_stream << "      <Value>" << std::setprecision(8) << std::fixed 
107✔
211
                        << RadtoDms(m_drValue) << "</Value>" << std::endl;
107✔
212
                *dynaml_stream << "      <StdDev>" << std::scientific << std::setprecision(6) << Seconds(m_dStdDev) << "</StdDev>" << std::endl;        
107✔
213
                
214
                if (m_msr_db_map.is_msr_id_set)
107✔
215
                        *dynaml_stream << "      <MeasurementID>" << m_msr_db_map.msr_id << "</MeasurementID>" << std::endl;
106✔
216
                
217
                *dynaml_stream << "    </Directions>" << std::endl;
107✔
218
        }
219
        else
220
        {
221
                // Zenith distance, vertical angle
222
                if (comment.empty())
359✔
223
                        *dynaml_stream << "  <!-- Type " << measurement_name<char, std::string>(GetTypeC()) << " -->" << std::endl;
1,077✔
224
                else
NEW
225
                        *dynaml_stream << "  <!-- " << comment << " -->" << std::endl;
×
226
        
227
                *dynaml_stream << "  <DnaMeasurement>" << std::endl;
359✔
228
                *dynaml_stream << "    <Type>" << m_strType << "</Type>" << std::endl;
359✔
229
                // Source file from which the measurement came
230
                *dynaml_stream << "    <Source>" << m_sourceFile << "</Source>" << std::endl;
359✔
231
                if (m_bIgnore)
359✔
232
                        *dynaml_stream << "    <Ignore>*</Ignore>" << std::endl;
25✔
233
                else
234
                        *dynaml_stream << "    <Ignore/>" << std::endl;
334✔
235
                
236
                if (m_epoch.empty())
359✔
237
                        *dynaml_stream << "    <Epoch/>" << std::endl;
355✔
238
                else
239
                        *dynaml_stream << "    <Epoch>" << m_epoch << "</Epoch>" << std::endl;
4✔
240

241
                *dynaml_stream << "    <First>" << m_strFirst << "</First>" << std::endl;
359✔
242
                *dynaml_stream << "    <Second>" << m_strTarget << "</Second>" << std::endl;
359✔
243
                *dynaml_stream << "    <Value>" << std::setprecision(8) << std::fixed 
359✔
244
                        << RadtoDms(m_drValue) << "</Value>" << std::endl;
359✔
245
                *dynaml_stream << "    <StdDev>" << std::scientific << std::setprecision(6) << Seconds(m_dStdDev) << "</StdDev>" << std::endl;        
359✔
246

247
                // Zenith distance, vertical angle
248
                switch (GetTypeC())
359✔
249
                {
250
                case 'Z':
329✔
251
                case 'V':
329✔
252
                        *dynaml_stream << "    <InstHeight>" << std::fixed << std::setprecision(3) << m_fInstHeight << "</InstHeight>" << std::endl;
329✔
253
                        *dynaml_stream << "    <TargHeight>" << std::fixed << std::setprecision(3) << m_fTargHeight << "</TargHeight>" << std::endl;
329✔
254
                        break;
329✔
255
                }
256
                
257
                if (m_msr_db_map.is_msr_id_set)
359✔
258
                        *dynaml_stream << "    <MeasurementID>" << m_msr_db_map.msr_id << "</MeasurementID>" << std::endl;
52✔
259
                
260
                *dynaml_stream << "  </DnaMeasurement>" << std::endl;
359✔
261
        }
262
}
466✔
263
        
264
void CDnaDirection::WriteDNAMsr(std::ofstream* dna_stream, const dna_msr_fields& dmw, const dna_msr_fields& dml, bool bSubMeasurement /*= false*/) const
344✔
265
{
266
        *dna_stream << std::setw(dmw.msr_type) << m_strType;
344✔
267
        if (m_bIgnore)
344✔
268
                *dna_stream << std::setw(dmw.msr_ignore) << "*";
13✔
269
        else
270
                *dna_stream << std::setw(dmw.msr_ignore) << " ";
331✔
271

272
        // database id width
273
        UINT32 width(dml.msr_id_msr - dml.msr_stddev - dmw.msr_stddev);
344✔
274

275
        if (bSubMeasurement)
344✔
276
        {
277
                // Direction set
278
                *dna_stream << std::left << std::setw(dmw.msr_inst) << " ";
13✔
279
                *dna_stream << std::setw(dmw.msr_targ1) << " ";
13✔
280
                *dna_stream << std::left << std::setw(dmw.msr_targ2) << m_strTarget;
13✔
281
                *dna_stream << std::setw(dmw.msr_linear) << " ";        // linear measurement value
13✔
282
                *dna_stream << std::setw(dmw.msr_ang_d + dmw.msr_ang_m + dmw.msr_ang_s) << 
13✔
283
                        std::right << FormatDnaDmsString(RadtoDms(m_drValue), 8);
26✔
284
                
285
                UINT32 m_stdDevPrec(3);
13✔
286
                *dna_stream << std::setw(dmw.msr_stddev) << StringFromTW(Seconds(m_dStdDev), dmw.msr_stddev, m_stdDevPrec);
39✔
287
                //*dna_stream << std::setw(dmw.msr_stddev) << std::fixed << std::setprecision(3) << Seconds(m_dStdDev);
288
        }
289
        else
290
        {
291
                // Azimuth, zenith distance, vertical angle
292
                *dna_stream << std::left << std::setw(dmw.msr_inst) << m_strFirst;
331✔
293
                *dna_stream << std::left << std::setw(dmw.msr_targ1) << m_strTarget;
331✔
294
                *dna_stream << std::setw(dmw.msr_targ2) << " ";
331✔
295
                *dna_stream << std::setw(dmw.msr_linear) << " ";        // linear measurement value
331✔
296
                *dna_stream << std::setw(dmw.msr_ang_d + dmw.msr_ang_m + dmw.msr_ang_s) << 
331✔
297
                        std::right << FormatDnaDmsString(RadtoDms(m_drValue), 8);
662✔
298
                
299
                UINT32 m_stdDevPrec(3);
331✔
300
                *dna_stream << std::setw(dmw.msr_stddev) << StringFromTW(Seconds(m_dStdDev), dmw.msr_stddev, m_stdDevPrec);
662✔
301
                //*dna_stream << std::setw(dmw.msr_stddev) << std::fixed << std::setprecision(3) << Seconds(m_dStdDev);
302
                width = dml.msr_gps_epoch - dml.msr_inst_ht;
331✔
303

304
                // Zenith distance, vertical angle
305
                switch (GetTypeC())
331✔
306
                {
307
                case 'Z':
315✔
308
                case 'V':
315✔
309
                        *dna_stream << std::setw(dmw.msr_inst_ht) << std::fixed << std::setprecision(3) << m_fInstHeight;
315✔
310
                        *dna_stream << std::setw(dmw.msr_targ_ht) << std::fixed << std::setprecision(3) << m_fTargHeight;
315✔
311
                        width = dml.msr_gps_epoch - dml.msr_targ_ht - dmw.msr_targ_ht;
315✔
312
                        break;
315✔
313
                }
314

315
                *dna_stream << std::setw(width) << " ";
331✔
316
                *dna_stream << std::setw(dmw.msr_gps_epoch) << m_epoch;
331✔
317
                width = 0;
331✔
318
        }
319

320
        if (m_msr_db_map.is_msr_id_set)
344✔
321
        {
322
                if (width)
36✔
323
                        *dna_stream << std::setw(width) << " ";
12✔
324
                *dna_stream << std::setw(dmw.msr_id_msr) << m_msr_db_map.msr_id;
36✔
325

326
                if (bSubMeasurement)
36✔
327
                        if (m_msr_db_map.is_cls_id_set)
12✔
328
                                *dna_stream << std::setw(dmw.msr_id_cluster) << m_msr_db_map.cluster_id;
12✔
329
        }
330

331
        *dna_stream << std::endl;
344✔
332
}
344✔
333
        
334
void CDnaDirection::SimulateMsr(vdnaStnPtr* vStations, const CDnaEllipsoid*)
5✔
335
{
336
        _it_vdnastnptr stn1_it(vStations->begin() + m_lstn1Index);
5✔
337
        _it_vdnastnptr stn2_it(vStations->begin() + m_lstn2Index);
5✔
338
        
339
        double zenithDistance;
5✔
340
        double direction;
5✔
341

342
        direction = Direction(
5✔
343
                stn1_it->get()->GetXAxis(), 
344
                stn1_it->get()->GetYAxis(),
345
                stn1_it->get()->GetZAxis(),
346
                stn2_it->get()->GetXAxis(), 
347
                stn2_it->get()->GetYAxis(),
348
                stn2_it->get()->GetZAxis(),
349
                stn1_it->get()->GetcurrentLatitude(),
350
                stn1_it->get()->GetcurrentLongitude());
351

352
        switch (GetTypeC())
5✔
353
        {
354
        
355
        // direction
356
        case 'D':        
1✔
357
                // assign direction
358
                m_drValue = direction;
1✔
359

360
                // Deflections available?
361
                if (fabs(stn1_it->get()->GetverticalDef()) > E4_SEC_DEFLECTION || fabs(stn1_it->get()->GetmeridianDef()) > E4_SEC_DEFLECTION)
1✔
362
                {
363
                        // 1. compute zenith distance 
364
                        zenithDistance = ZenithDistance<double>(
1✔
365
                                stn1_it->get()->GetXAxis(), 
366
                                stn1_it->get()->GetYAxis(),
367
                                stn1_it->get()->GetZAxis(),
368
                                stn2_it->get()->GetXAxis(), 
369
                                stn2_it->get()->GetYAxis(),
370
                                stn2_it->get()->GetZAxis(),
371
                                stn1_it->get()->GetcurrentLatitude(),
372
                                stn1_it->get()->GetcurrentLongitude(),
373
                                stn2_it->get()->GetcurrentLatitude(),
374
                                stn2_it->get()->GetcurrentLongitude(),
375
                                0.0,                                
376
                                0.0);        
377

378
                        // 2. Compute deflection
379
                        m_preAdjCorr = DirectionDeflectionCorrection<double>(
1✔
380
                                m_drValue,
381
                                zenithDistance,
382
                                stn1_it->get()->GetverticalDef(),                        // deflection in prime vertical
383
                                stn1_it->get()->GetmeridianDef());                        // deflection in prime meridian
384
                        
385
                        // 3. apply deflection correction
386
                        m_drValue += m_preAdjCorr;
1✔
387
                }
388
                break;
389
        
390
        // geodetic azimuth
391
        case 'B':        
1✔
392
                // assign direction
393
                m_drValue = direction;
1✔
394
                m_epoch = "01.10.1985";
1✔
395
                break;
396
        
397
        // astronomic azimuth
398
        case 'K':        
1✔
399
                // assign direction
400
                m_drValue = direction;
1✔
401

402
                // Deflections available?
403
                if (fabs(stn1_it->get()->GetverticalDef()) > E4_SEC_DEFLECTION || fabs(stn1_it->get()->GetmeridianDef()) > E4_SEC_DEFLECTION)
1✔
404
                {
405
                        // 1. compute zenith distance 
406
                        zenithDistance = ZenithDistance<double>(
1✔
407
                                stn1_it->get()->GetXAxis(), 
408
                                stn1_it->get()->GetYAxis(),
409
                                stn1_it->get()->GetZAxis(),
410
                                stn2_it->get()->GetXAxis(), 
411
                                stn2_it->get()->GetYAxis(),
412
                                stn2_it->get()->GetZAxis(),
413
                                stn1_it->get()->GetcurrentLatitude(),
414
                                stn1_it->get()->GetcurrentLongitude(),
415
                                stn2_it->get()->GetcurrentLatitude(),
416
                                stn2_it->get()->GetcurrentLongitude(),
417
                                0.0,                                
418
                                0.0);        
419

420
                        // 2. Compute correction
421
                        m_preAdjCorr = LaplaceCorrection<double>(                // Laplace correction
1✔
422
                                m_drValue,                                                                        // geodetic azimuth
423
                                zenithDistance,                                                                // zenith distance
424
                                stn1_it->get()->GetverticalDef(),                        // deflection in prime vertical
425
                                stn1_it->get()->GetmeridianDef(),                        // deflection in prime meridian
426
                                stn1_it->get()->GetcurrentLatitude());
427

428
                        // 3. apply deflection correction
429
                        m_drValue += m_preAdjCorr;
1✔
430
                }
431
                m_epoch = "01.10.1985";
1✔
432
                break;
433
        
434
        // vertical angle
435
        case 'Z':
1✔
436
                m_fInstHeight = float(1.650);
1✔
437
                m_fTargHeight = float(1.651);
1✔
438

439
                // compute vertical angle 
440
                m_drValue = VerticalAngle<double>(
1✔
441
                        stn1_it->get()->GetXAxis(), 
442
                        stn1_it->get()->GetYAxis(),
443
                        stn1_it->get()->GetZAxis(),
444
                        stn2_it->get()->GetXAxis(), 
445
                        stn2_it->get()->GetYAxis(),
446
                        stn2_it->get()->GetZAxis(),
447
                        stn1_it->get()->GetcurrentLatitude(),
448
                        stn1_it->get()->GetcurrentLongitude(),
449
                        stn2_it->get()->GetcurrentLatitude(),
450
                        stn2_it->get()->GetcurrentLongitude(),
451
                        m_fInstHeight,                                
452
                        m_fTargHeight);
453

454
                // Deflections available?
455
                if (fabs(stn1_it->get()->GetverticalDef()) > E4_SEC_DEFLECTION || fabs(stn1_it->get()->GetmeridianDef()) > E4_SEC_DEFLECTION)
1✔
456
                {
457
                        // 1. compute bearing from estimated coordinates
458
                        // see above
459
                        
460
                        // 2. Compute correction
461
                        m_preAdjCorr = ZenithDeflectionCorrection<double>(        // Correction to vertical angle for deflection of vertical
1✔
462
                                direction,                                                                                // geodetic azimuth
463
                                stn1_it->get()->GetverticalDef(),                                // deflection in prime vertical
464
                                stn1_it->get()->GetmeridianDef());                                // deflection in prime meridian
465

466
                        // 3. apply deflection correction (in reverse 
467
                        // to get the simulated observation)
468
                        m_drValue += m_preAdjCorr;
1✔
469
                }
470
                m_epoch = "01.10.1985";
1✔
471
                break;
472
        
473
        // zenith distance
474
        case 'V':
1✔
475
                m_fInstHeight = float(1.650);
1✔
476
                m_fTargHeight = float(1.651);
1✔
477

478
                // compute zenith distance 
479
                m_drValue = ZenithDistance<double>(
1✔
480
                        stn1_it->get()->GetXAxis(), 
481
                        stn1_it->get()->GetYAxis(),
482
                        stn1_it->get()->GetZAxis(),
483
                        stn2_it->get()->GetXAxis(), 
484
                        stn2_it->get()->GetYAxis(),
485
                        stn2_it->get()->GetZAxis(),
486
                        stn1_it->get()->GetcurrentLatitude(),
487
                        stn1_it->get()->GetcurrentLongitude(),
488
                        stn2_it->get()->GetcurrentLatitude(),
489
                        stn2_it->get()->GetcurrentLongitude(),
490
                        m_fInstHeight,
491
                        m_fTargHeight);
492

493
                // Deflections available?
494
                if (fabs(stn1_it->get()->GetverticalDef()) > E4_SEC_DEFLECTION || fabs(stn1_it->get()->GetmeridianDef()) > E4_SEC_DEFLECTION)
1✔
495
                {
496
                        // 1. compute bearing from estimated coordinates
497
                        // see above
498

499
                        // 2. Compute correction
500
                        m_preAdjCorr = ZenithDeflectionCorrection<double>(        // Correction to zenith distance for deflection of vertical
1✔
501
                                direction,                                                                                // geodetic azimuth
502
                                stn1_it->get()->GetverticalDef(),                                // deflection in prime vertical
503
                                stn1_it->get()->GetmeridianDef());                                // deflection in prime meridian
504

505
                        // 3. apply deflection correction (in reverse 
506
                        // to get the simulated observation)
507
                        m_drValue -= m_preAdjCorr;
1✔
508
                }
509
        }
510

511
        m_dStdDev = SecondstoRadians(0.010);
5✔
512

513
        m_epoch = "01.10.1985";
5✔
514
}
5✔
515
        
516

517
//UINT32 CDnaDirection::SetMeasurementRec(std::ifstream* ifs_stns, std::ifstream* ifs_msrs, measurement_t* measRecord)
518
//{
519
//        char stationName[STN_NAME_WIDTH];
520
//
521
//        if (GetTypeC() == 'D')                // part of a DnaDirectionSet
522
//        {
523
//                // get data relating to each direction
524
//                if (ifs_msrs->eof() || !ifs_msrs->good())
525
//                        throw XMLInteropException("SetMeasurementRec(): Errors were encountered when reading from the binary measurement file.", 0);
526
//                ifs_msrs->read(reinterpret_cast<char *>(measRecord), sizeof(measurement_t));
527
//        }
528
//
529
//        m_bIgnore = measRecord->ignore;
530
//        m_lsetID = measRecord->clusterID;
531
//        m_MSmeasurementStations = (MEASUREMENT_STATIONS)measRecord->measurementStations;
532
//        // measRecord holds the full number of measurement blocks, which is 
533
//        // the numberofdirections in the vector plus one for the RO
534
//        m_lRecordedTotal = measRecord->vectorCount1;
535
//
536
//        if (GetTypeC() != 'D')                // not part of a DnaDirectionSet (e.g. vertical angle, zenith distance)
537
//        {
538
//                m_strType = measRecord->measType;
539
//                
540
//                // first station
541
//                m_lstn1Index = measRecord->station1;
542
//                ifs_stns->seekg(sizeof(UINT32) + measRecord->station1 * sizeof(station_t), std::ios::beg);
543
//                ifs_stns->read(reinterpret_cast<char *>(&stationName), sizeof(stationName));
544
//                m_strFirst = stationName;
545
//
546
//                m_fInstHeight = static_cast<float> (measRecord->term3);
547
//                m_fTargHeight = static_cast<float> (measRecord->term4);
548
//        }
549
//
550
//        // target station
551
//        m_lstn2Index = measRecord->station2;
552
//        ifs_stns->seekg(sizeof(UINT32) + measRecord->station2 * sizeof(station_t), std::ios::beg);
553
//        ifs_stns->read(reinterpret_cast<char *>(&stationName), sizeof(stationName));
554
//        m_strTarget = stationName;
555
//        
556
//        m_measAdj = measRecord->measAdj;
557
//        m_measCorr = measRecord->measCorr;
558
//        m_measAdjPrec = measRecord->measAdjPrec;
559
//        m_residualPrec = measRecord->residualPrec;
560
//        m_preAdjCorr = measRecord->preAdjCorr;
561
//        m_drValue = measRecord->term1;
562
//        m_dStdDev = sqrt(measRecord->term2);
563
//        
564
//        return 1;
565
//}
566
        
567

568
UINT32 CDnaDirection::SetMeasurementRec(const vstn_t& binaryStn, it_vmsr_t& it_msr, it_vdbid_t& dbidmap)
193✔
569
{
570
        m_bIgnore = it_msr->ignore;
193✔
571
        m_lsetID = it_msr->clusterID;
193✔
572
        m_MSmeasurementStations = (MEASUREMENT_STATIONS)it_msr->measurementStations;
193✔
573
        // it_msr holds the full number of measurement blocks, which is 
574
        // the numberofdirections in the vector plus one for the RO
575
        m_lRecordedTotal = it_msr->vectorCount1;
193✔
576

577
        if (it_msr->measType != 'D')                // not part of a DnaDirectionSet (e.g. vertical angle, zenith distance)
193✔
578
        {
579
                m_strType = it_msr->measType;
173✔
580
                
581
                // first station
582
                m_lstn1Index = it_msr->station1;
173✔
583
                m_strFirst = binaryStn.at(it_msr->station1).stationName;
173✔
584
                // inst and targ heights
585
                m_fInstHeight = static_cast<float> (it_msr->term3);
173✔
586
                m_fTargHeight = static_cast<float> (it_msr->term4);
173✔
587
        }
588

589
        // target station
590
        m_lstn2Index = it_msr->station2;
193✔
591
        m_strTarget = binaryStn.at(it_msr->station2).stationName;
193✔
592
        
593
        m_measAdj = it_msr->measAdj;
193✔
594
        m_measCorr = it_msr->measCorr;
193✔
595
        m_measAdjPrec = it_msr->measAdjPrec;
193✔
596
        m_residualPrec = it_msr->residualPrec;
193✔
597
        m_preAdjCorr = it_msr->preAdjCorr;
193✔
598
        m_drValue = it_msr->term1;
193✔
599
        m_dStdDev = sqrt(it_msr->term2);
193✔
600

601
        m_epoch = it_msr->epoch;
193✔
602

603
        CDnaMeasurement::SetDatabaseMap(*dbidmap);
193✔
604
        
605
        return 0;
193✔
606
}
607
        
608

609
void CDnaDirection::WriteBinaryMsr(std::ofstream* binary_stream, PUINT32 msrIndex) const
12,376✔
610
{
611
        measurement_t measRecord;
12,376✔
612
        measRecord.measType = GetTypeC();
12,376✔
613
        if (m_strType == "D")
12,376✔
614
                measRecord.measStart = yMeas;
510✔
615
        else
616
                measRecord.measStart = xMeas;
11,866✔
617
        measRecord.ignore = m_bIgnore;
12,376✔
618
        measRecord.station1 = m_lstn1Index;
12,376✔
619
        measRecord.station2 = m_lstn2Index;
12,376✔
620
        measRecord.measAdj = m_measAdj;
12,376✔
621
        measRecord.measCorr = m_measCorr;
12,376✔
622
        measRecord.measAdjPrec = m_measAdjPrec;
12,376✔
623
        measRecord.residualPrec = m_residualPrec;
12,376✔
624
        measRecord.preAdjCorr = m_preAdjCorr;
12,376✔
625
        measRecord.term1 = m_drValue;
12,376✔
626
        measRecord.term2 = m_dStdDev * m_dStdDev;        // convert to variance
12,376✔
627
        measRecord.term3 = m_fInstHeight;
12,376✔
628
        measRecord.term4 = m_fTargHeight;
12,376✔
629

630
        measRecord.clusterID = m_lsetID;
12,376✔
631
        // number of Directions in the parent cluster including the first
632
        measRecord.vectorCount1 = m_lRecordedTotal;
12,376✔
633
        measRecord.measurementStations = m_MSmeasurementStations;
12,376✔
634
        measRecord.fileOrder = ((*msrIndex)++);
12,376✔
635

636
        sprintf(measRecord.epoch, "%s", m_epoch.substr(0, STN_EPOCH_WIDTH).c_str());
12,376✔
637

638
        binary_stream->write(reinterpret_cast<char *>(&measRecord), sizeof(measurement_t));
12,376✔
639
}
12,376✔
640

641

642
//void CDnaDirection::coutDirectionData(std::ostream &os) const
643
//{
644
//        os << std::setw(16) << " " << std::setw(MSR2_WIDTH) << m_strTarget;
645
//        os << std::setw(3) << (m_bIgnore ? "*" : " ") << std::setw(MEAS_WIDTH) << m_drValue;
646
//        os << std::setw(VAR_WIDTH) << m_dStdDev;
647
//        os << std::setw(7) << " ";        // m_fInstHeight
648
//        switch (GetTypeC())
649
//        {
650
//        case 'Z':
651
//        case 'V':
652
//                os << std::setw(7) << std::setprecision(3) << std::fixed << m_fTargHeight;
653
//                break;
654
//        default:
655
//                os << std::setw(7) << " ";
656
//                break;
657
//        }
658
//        os << std::endl;
659
//}
660

661
void CDnaDirection::SetValue(const std::string& str)
13,056✔
662
{
663
        RadFromDmsString(&m_drValue, trimstr(str));
13,056✔
664
}
13,056✔
665

666
void CDnaDirection::SetStdDev(const std::string& str)
13,056✔
667
{
668
        // convert seconds to radians
669
        RadFromSecondsString(&m_dStdDev, trimstr(str));
13,056✔
670
}
13,056✔
671

672
// Instrument and target heights only make sense for 
673
// slope distances, vertical angles and zenith distances.
674
// Note: vertical angles and zenith distances are derived
675
// from CDnaDirection, so these methods are provided here,
676
// but don't need instrument height for 'D' measurements.
677
void CDnaDirection::SetInstrumentHeight(const std::string& str)
12,385✔
678
{
679
        FloatFromString<float>(m_fInstHeight, trimstr(str));
12,385✔
680
}
12,385✔
681

682
void CDnaDirection::SetTargetHeight(const std::string& str)
12,385✔
683
{
684
        FloatFromString<float>(m_fTargHeight, trimstr(str));
12,385✔
685
}
12,385✔
686

687

688

689

690

691

692

693

694

695

696

697

698
CDnaAzimuth::CDnaAzimuth(void)
150✔
699
{
700
        m_strType = "";                // could be B or K
150✔
701
        m_strTarget = "";
150✔
702
        m_drValue = 0.;
150✔
703
        m_dStdDev = 0.;
150✔
704
        m_fInstHeight = 0.;
150✔
705
        m_fTargHeight = 0.;
150✔
706
        m_lRecordedTotal = 0;
150✔
707
        m_lsetID = 0;
150✔
708
        m_MSmeasurementStations = TWO_STATION;
150✔
709

710
}
150✔
711

712
CDnaAzimuth::~CDnaAzimuth(void)
220✔
713
{
714
}
220✔
715

716
// copy constructors
717
//CDnaAzimuth::CDnaAzimuth(const CDnaAzimuth& newAzimuth)
718
//{
719
//        m_strType = newAzimuth.m_strType;
720
//        m_strFirst = newAzimuth.m_strFirst;
721
//        m_bIgnore = newAzimuth.m_bIgnore;
722
//        m_strTarget = newAzimuth.m_strTarget;
723
//        m_drValue = newAzimuth.m_drValue;
724
//        m_dStdDev = newAzimuth.m_dStdDev;
725
//        m_MSmeasurementStations = newAzimuth.m_MSmeasurementStations;
726
//
727
//}
728

729

730
//CDnaAzimuth::CDnaAzimuth(const bool bIgnore, const std::string& strFirst, const std::string& strTarget, const double& drValue, const double& dStdDev)
731
//{
732
//        m_bIgnore = bIgnore;
733
//        m_strTarget = strTarget;
734
//        m_drValue = drValue;
735
//        m_dStdDev = dStdDev;
736
//}
737

738

739
//CDnaAzimuth& CDnaAzimuth::operator= (const CDnaAzimuth& rhs)
740
//{
741
//        // check for assignment to self!
742
//        if (this == &rhs)
743
//                return *this;
744
//
745
//        CDnaMeasurement::operator=(rhs);
746
//        m_strTarget = rhs.m_strTarget;
747
//        m_drValue = rhs.m_drValue;
748
//        m_dStdDev = rhs.m_dStdDev;
749
//        m_lRecordedTotal = rhs.m_lRecordedTotal;
750
//        m_lsetID = rhs.m_lsetID;
751
//        m_MSmeasurementStations = rhs.m_MSmeasurementStations;
752
//
753
//        return *this;
754
//}
755

756

757
bool CDnaAzimuth::operator== (const CDnaAzimuth& rhs) const
4✔
758
{
759
        return (
4✔
760
                m_strFirst == rhs.m_strFirst &&
8✔
761
                m_bIgnore == rhs.m_bIgnore &&
4✔
762
                m_strTarget == rhs.m_strTarget &&
4✔
763
                m_drValue == rhs.m_drValue &&
4✔
764
                m_dStdDev == rhs.m_dStdDev &&
4✔
765
                m_strType == rhs.m_strType &&
8✔
766
                m_epoch == rhs.m_epoch
4✔
767
                );
4✔
768
}
769

770
}        // namespace measurements
771
}        // 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

© 2025 Coveralls, Inc