• 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

97.79
/dynadjust/include/measurement_types/dnaangle.cpp
1
//============================================================================
2
// Name         : dnaangle.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  : CDnaAngle implementation file
21
//============================================================================
22

23
#include <include/measurement_types/dnaangle.hpp>
24

25
namespace dynadjust {
26
namespace measurements {
27

28
CDnaAngle::CDnaAngle(void)
10,428✔
29
        : m_strTarget("")
20,856✔
30
        , m_strTarget2("")
10,428✔
31
        , m_drValue(0.)
10,428✔
32
        , m_dStdDev(0.)
10,428✔
33
{
34
        // from abstract class
35
        m_strType = "A";
10,428✔
36
        m_MSmeasurementStations = THREE_STATION;
10,428✔
37
}
10,428✔
38

39
CDnaAngle::~CDnaAngle(void)
17,316✔
40
{
41
}
34,632✔
42
        
43

44
bool CDnaAngle::operator== (const CDnaAngle& rhs) const
251✔
45
{
46
        return (
251✔
47
                m_strFirst == rhs.m_strFirst &&
399✔
48
                m_strType == rhs.m_strType &&
148✔
49
                m_bIgnore == rhs.m_bIgnore &&
148✔
50
                m_strTarget == rhs.m_strTarget &&
148✔
51
                m_strTarget2 == rhs.m_strTarget2 &&
134✔
52
                m_drValue == rhs.m_drValue &&
4✔
53
                m_dStdDev == rhs.m_dStdDev &&
253✔
54
                m_epoch == rhs.m_epoch
2✔
55
                );
251✔
56
}
57

58
bool CDnaAngle::operator< (const CDnaAngle& rhs) const
2,689✔
59
{
60
        if (m_strFirst == rhs.m_strFirst) {                
2,689✔
61
                if (m_strTarget == rhs.m_strTarget) {
339✔
62
                        if (m_strTarget2 == rhs.m_strTarget2) {
283✔
63
                                if (m_bIgnore == rhs.m_bIgnore) {
6✔
64
                                        if (m_epoch == rhs.m_epoch) {
6✔
65
                                                if (m_drValue == rhs.m_drValue)
6✔
66
                                                        return m_dStdDev < rhs.m_dStdDev;
4✔
67
                                                else
68
                                                        return m_drValue < rhs.m_drValue; }
2✔
69
                                        else
70
                                                return m_epoch < rhs.m_epoch; }
×
71
                                else
72
                                        return m_bIgnore < rhs.m_bIgnore; }                
×
73
                        else
74
                                return m_strTarget2 < rhs.m_strTarget2; }
277✔
75
                else
76
                        return m_strTarget < rhs.m_strTarget; }                
56✔
77
        else
78
                return m_strFirst < rhs.m_strFirst;
2,350✔
79
}
80
        
81

82
void CDnaAngle::WriteDynaMLMsr(std::ofstream* dynaml_stream, const std::string& comment, bool) const
265✔
83
{
84
        if (comment.empty())
265✔
85
                *dynaml_stream << "  <!-- Type " << measurement_name<char, std::string>(GetTypeC()) << " -->" << std::endl;
795✔
86
        else
NEW
87
                *dynaml_stream << "  <!-- " << comment << " -->" << std::endl;
×
88

89
        *dynaml_stream << "  <DnaMeasurement>" << std::endl;
265✔
90
        *dynaml_stream << "    <Type>" << m_strType << "</Type>" << std::endl;
265✔
91
        // Source file from which the measurement came
92
        *dynaml_stream << "    <Source>" << m_sourceFile << "</Source>" << std::endl;
265✔
93
        if (m_bIgnore)
265✔
94
                *dynaml_stream << "    <Ignore>*</Ignore>" << std::endl;
6✔
95
        else
96
                *dynaml_stream << "    <Ignore/>" << std::endl;
259✔
97

98
        if (m_epoch.empty())
265✔
99
                *dynaml_stream << "    <Epoch/>" << std::endl;
264✔
100
        else
101
                *dynaml_stream << "    <Epoch>" << m_epoch << "</Epoch>" << std::endl;
1✔
102

103
        *dynaml_stream << "    <First>" << m_strFirst << "</First>" << std::endl;
265✔
104
        *dynaml_stream << "    <Second>" << m_strTarget << "</Second>" << std::endl;
265✔
105
        *dynaml_stream << "    <Third>" << m_strTarget2 << "</Third>" << std::endl;
265✔
106
        *dynaml_stream << "    <Value>" << std::setprecision(8) << std::fixed << RadtoDms(m_drValue) << "</Value>" << std::endl;
265✔
107
        *dynaml_stream << "    <StdDev>" << std::scientific << std::setprecision(6) << Seconds(m_dStdDev) << "</StdDev>" << std::endl;
265✔
108
        
109
        if (m_msr_db_map.is_msr_id_set)
265✔
110
                *dynaml_stream << "    <MeasurementID>" << m_msr_db_map.msr_id << "</MeasurementID>" << std::endl;
13✔
111
        
112
        *dynaml_stream << "  </DnaMeasurement>" << std::endl;
265✔
113
}
265✔
114
        
115

116
void CDnaAngle::WriteDNAMsr(std::ofstream* dna_stream, const dna_msr_fields& dmw, const dna_msr_fields& dml, bool) const
258✔
117
{
118
        *dna_stream << std::setw(dmw.msr_type) << m_strType;
258✔
119
        if (m_bIgnore)
258✔
120
                *dna_stream << std::setw(dmw.msr_ignore) << "*";
3✔
121
        else
122
                *dna_stream << std::setw(dmw.msr_ignore) << " ";
255✔
123
        *dna_stream << std::left << std::setw(dmw.msr_inst) << m_strFirst;
258✔
124
        *dna_stream << std::left << std::setw(dmw.msr_targ1) << m_strTarget;
258✔
125
        *dna_stream << std::left << std::setw(dmw.msr_targ2) << m_strTarget2;
258✔
126
        *dna_stream << std::setw(dmw.msr_linear) << " ";        // linear measurement value
258✔
127
        *dna_stream << std::setw(dmw.msr_ang_d + dmw.msr_ang_m + dmw.msr_ang_s) << 
258✔
128
                std::right << FormatDnaDmsString(RadtoDms(m_drValue), 8);
516✔
129
        
130
        UINT32 m_stdDevPrec(3);
258✔
131
        *dna_stream << std::setw(dmw.msr_stddev) << StringFromTW(Seconds(m_dStdDev), dmw.msr_stddev, m_stdDevPrec);
516✔
132
        //*dna_stream << std::setw(dmw.msr_stddev) << std::fixed << std::setprecision(3) << Seconds(m_dStdDev);
133
        
134
        *dna_stream << std::setw(dml.msr_gps_epoch - dml.msr_inst_ht) << " ";
258✔
135
        *dna_stream << std::setw(dmw.msr_gps_epoch) << m_epoch;
258✔
136

137
        if (m_msr_db_map.is_msr_id_set)
258✔
138
                *dna_stream << std::setw(dmw.msr_id_msr) << m_msr_db_map.msr_id;
6✔
139
        
140
        *dna_stream << std::endl;
258✔
141
}
258✔
142
        
143

144
void CDnaAngle::SimulateMsr(vdnaStnPtr* vStations, const CDnaEllipsoid*)
1✔
145
{
146
        _it_vdnastnptr stn1_it(vStations->begin() + m_lstn1Index);
1✔
147
        _it_vdnastnptr stn2_it(vStations->begin() + m_lstn2Index);
1✔
148
        _it_vdnastnptr stn3_it(vStations->begin() + m_lstn3Index);
1✔
149

150
        double direction12, direction13;
1✔
151

152
        // calculated angle
153
        m_drValue = HorizontalAngle(
1✔
154
                stn1_it->get()->GetXAxis(),
155
                stn1_it->get()->GetYAxis(),
156
                stn1_it->get()->GetZAxis(),
157
                stn2_it->get()->GetXAxis(),
158
                stn2_it->get()->GetYAxis(),
159
                stn2_it->get()->GetZAxis(),
160
                stn3_it->get()->GetXAxis(),
161
                stn3_it->get()->GetYAxis(),
162
                stn3_it->get()->GetZAxis(),
163
                stn1_it->get()->GetcurrentLatitude(),
164
                stn1_it->get()->GetcurrentLongitude(),
165
                &direction12, &direction13);
166

167
        // Deflections available?
168
        if (fabs(stn1_it->get()->GetverticalDef()) > E4_SEC_DEFLECTION || fabs(stn1_it->get()->GetmeridianDef()) > E4_SEC_DEFLECTION)
1✔
169
        {
170
                /////////////////////////////////////////////////////////////////////////////////
171
                // Angles (observed or derived from directions) must be corrected for deflection 
172
                // of the vertical via "Laplace correction".  This correction requires zenith 
173
                // distance (zenith12, zenith13) and geodetic azimuth (direction12, direction13), 
174
                // both of which must be computed from coordinates.
175
                
176
                // 1. Compute zenith distance 1 -> 2
177
                double zenith12(ZenithDistance<double>(
1✔
178
                        stn1_it->get()->GetXAxis(),
179
                        stn1_it->get()->GetYAxis(),
180
                        stn1_it->get()->GetZAxis(),
181
                        stn2_it->get()->GetXAxis(),
182
                        stn2_it->get()->GetYAxis(),
183
                        stn2_it->get()->GetZAxis(),
184
                        stn1_it->get()->GetcurrentLatitude(),
185
                        stn1_it->get()->GetcurrentLongitude(),
186
                        stn2_it->get()->GetcurrentLatitude(),
187
                        stn2_it->get()->GetcurrentLongitude(),
188
                        0.0,                                                                        // instrument height
189
                        0.0));                                                                        // target height
190

191
                // 2. Compute zenith distance 1 -> 3
192
                double zenith13(ZenithDistance<double>(
1✔
193
                        stn1_it->get()->GetXAxis(),
194
                        stn1_it->get()->GetYAxis(),
195
                        stn1_it->get()->GetZAxis(),
196
                        stn3_it->get()->GetXAxis(),
197
                        stn3_it->get()->GetYAxis(),
198
                        stn3_it->get()->GetZAxis(),
199
                        stn1_it->get()->GetcurrentLatitude(),
200
                        stn1_it->get()->GetcurrentLongitude(),
201
                        stn3_it->get()->GetcurrentLatitude(),
202
                        stn3_it->get()->GetcurrentLongitude(),
203
                        0.0,                                                                        // instrument height
204
                        0.0));                                                                        // target height
205

206
                // 3. Laplace correction 1 -> 2 -> 3
207
                m_preAdjCorr = HzAngleDeflectionCorrection<double>(                
1✔
208
                        direction12,                                                        // geodetic azimuth 1 -> 2
209
                        zenith12,                                                                // zenith distance 1 -> 2
210
                        direction13,                                                        // geodetic azimuth 1 -> 3
211
                        zenith13,                                                                // zenith distance 1 -> 3
212
                        stn1_it->get()->GetverticalDef(),                // deflection in prime vertical
213
                        stn1_it->get()->GetmeridianDef());                // deflection in prime meridian
214

215
                // 4. apply deflection correction
216
                m_drValue += m_preAdjCorr;
1✔
217
        }
218

219
        // compute standard deviation in radians
220
        m_dStdDev = SecondstoRadians(0.01);
1✔
221

222
        m_epoch = "01.10.1985";
1✔
223
}
1✔
224
        
225

226
UINT32 CDnaAngle::SetMeasurementRec(const vstn_t& binaryStn, it_vmsr_t& it_msr, it_vdbid_t& dbidmap)
114✔
227
{
228
        m_strType = it_msr->measType;
114✔
229
        m_bIgnore = it_msr->ignore;
114✔
230
        m_MSmeasurementStations = (MEASUREMENT_STATIONS)it_msr->measurementStations;
114✔
231
        
232
        // first station
233
        m_lstn1Index = it_msr->station1;
114✔
234
        m_strFirst = binaryStn.at(it_msr->station1).stationName;
114✔
235

236
        // target station
237
        m_lstn2Index = it_msr->station2;
114✔
238
        m_strTarget = binaryStn.at(it_msr->station2).stationName;
114✔
239
        
240
        // target2 station
241
        m_lstn3Index = it_msr->station3;
114✔
242
        m_strTarget2 = binaryStn.at(it_msr->station3).stationName;
114✔
243
        
244
        m_measAdj = it_msr->measAdj;
114✔
245
        m_measCorr = it_msr->measCorr;
114✔
246
        m_measAdjPrec = it_msr->measAdjPrec;
114✔
247
        m_residualPrec = it_msr->residualPrec;
114✔
248
        m_preAdjCorr = it_msr->preAdjCorr;
114✔
249
        m_drValue = it_msr->term1;
114✔
250
        m_dStdDev = sqrt(it_msr->term2);
114✔
251
        
252
        m_epoch = it_msr->epoch;
114✔
253

254
        CDnaMeasurement::SetDatabaseMap(*dbidmap);
114✔
255

256
        return 0;
114✔
257
}
258

259
void CDnaAngle::WriteBinaryMsr(std::ofstream* binary_stream, PUINT32 msrIndex) const
10,061✔
260
{
261
        measurement_t measRecord;
10,061✔
262
        measRecord.measType = GetTypeC();
10,061✔
263
        measRecord.measStart = xMeas;
10,061✔
264
        measRecord.ignore = m_bIgnore;
10,061✔
265
        measRecord.station1 = m_lstn1Index;
10,061✔
266
        measRecord.station2 = m_lstn2Index;
10,061✔
267
        measRecord.station3 = m_lstn3Index;
10,061✔
268
        measRecord.measAdj = m_measAdj;
10,061✔
269
        measRecord.measCorr = m_measCorr;
10,061✔
270
        measRecord.measAdjPrec = m_measAdjPrec;
10,061✔
271
        measRecord.residualPrec = m_residualPrec;
10,061✔
272
        measRecord.preAdjCorr = m_preAdjCorr;
10,061✔
273
        measRecord.term1 = m_drValue;
10,061✔
274
        measRecord.term2 = m_dStdDev * m_dStdDev;        // convert to variance
10,061✔
275
        measRecord.measurementStations = m_MSmeasurementStations;
10,061✔
276
        measRecord.fileOrder = ((*msrIndex)++);
10,061✔
277

278
        sprintf(measRecord.epoch, "%s", m_epoch.substr(0, STN_EPOCH_WIDTH).c_str());
10,061✔
279

280
        binary_stream->write(reinterpret_cast<char *>(&measRecord), sizeof(measurement_t));
10,061✔
281
}
10,061✔
282

283
void CDnaAngle::SetValue(const std::string& str)
10,313✔
284
{
285
        // convert to radians
286
        RadFromDmsString(&m_drValue, trimstr(str));
10,313✔
287
}
10,313✔
288

289
void CDnaAngle::SetStdDev(const std::string& str)
10,313✔
290
{
291
        // convert seconds to radians
292
        RadFromSecondsString(&m_dStdDev, trimstr(str));
10,313✔
293
}
10,313✔
294

295
}        // namespace measurements
296
}        // 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