• 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

95.65
/dynadjust/include/measurement_types/dnaheightdifference.cpp
1
//============================================================================
2
// Name         : dnaheightdifference.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  : CDnaHeightDifference implementation file
21
//============================================================================
22

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

25
//extern boost::random::mt19937 rng;
26
//extern boost::random::uniform_real_distribution<double> stdev;
27
//extern boost::random::uniform_real_distribution<double> pertu;
28

29
namespace dynadjust {
30
namespace measurements {
31

32
CDnaHeightDifference::CDnaHeightDifference(void)
3,685✔
33
        : m_strTarget("")
7,370✔
34
        , m_dValue(0.)
3,685✔
35
        , m_dStdDev(0.)
3,685✔
36
{
37
        m_strType = "L";                // default is Slope distance, but could also be 'C' or 'E' or 'M'
3,685✔
38
        m_MSmeasurementStations = TWO_STATION;
3,685✔
39
}
3,685✔
40

41

42
CDnaHeightDifference::~CDnaHeightDifference(void)
6,098✔
43
{
44

45
}
9,147✔
46
        
47

48
bool CDnaHeightDifference::operator== (const CDnaHeightDifference& rhs) const
90✔
49
{
50
        return (
90✔
51
                m_strFirst == rhs.m_strFirst &&
148✔
52
                m_strTarget == rhs.m_strTarget &&
58✔
53
                m_strType == rhs.m_strType &&
5✔
54
                m_bIgnore == rhs.m_bIgnore &&
5✔
55
                m_dValue == rhs.m_dValue &&
4✔
56
                m_dStdDev == rhs.m_dStdDev &&
93✔
57
                m_epoch == rhs.m_epoch
3✔
58
                );
90✔
59
}
60

61

62
bool CDnaHeightDifference::operator< (const CDnaHeightDifference& rhs) const
772✔
63
{
64
        if (m_strFirst == rhs.m_strFirst) {
772✔
65
                if (m_strType == rhs.m_strType) {        // don't think this is needed
299✔
66
                        if (m_bIgnore == rhs.m_bIgnore) {
299✔
67
                                if (m_epoch == rhs.m_epoch) {
299✔
68
                                        if (m_strTarget == rhs.m_strTarget) {
299✔
69
                                                if (m_dValue == rhs.m_dValue)
8✔
70
                                                        return m_dStdDev < rhs.m_dStdDev; 
4✔
71
                                                else
72
                                                        return m_dValue < rhs.m_dValue; }
4✔
73
                                        else
74
                                                return m_strTarget < rhs.m_strTarget; }
291✔
75
                                else
76
                                        return m_epoch < rhs.m_epoch; }
×
77
                        else
78
                                return m_bIgnore < rhs.m_bIgnore; }
×
79
                else
80
                        return m_strType < rhs.m_strType; }
×
81
        else
82
                return m_strFirst < rhs.m_strFirst;
473✔
83
}
84
        
85

86
void CDnaHeightDifference::WriteDynaMLMsr(std::ofstream* dynaml_stream, const std::string& comment, bool) const
104✔
87
{
88
        if (comment.empty())
104✔
89
                *dynaml_stream << "  <!-- Type " << measurement_name<char, std::string>(GetTypeC()) << " -->" << std::endl;
312✔
90
        else
NEW
91
                *dynaml_stream << "  <!-- " << comment << " -->" << std::endl;
×
92

93
        *dynaml_stream << "  <DnaMeasurement>" << std::endl;
104✔
94
        *dynaml_stream << "    <Type>" << m_strType << "</Type>" << std::endl;
104✔
95
        // Source file from which the measurement came
96
        *dynaml_stream << "    <Source>" << m_sourceFile << "</Source>" << std::endl;
104✔
97
        if (m_bIgnore)
104✔
98
                *dynaml_stream << "    <Ignore>*</Ignore>" << std::endl;
4✔
99
        else
100
                *dynaml_stream << "    <Ignore/>" << std::endl;
100✔
101
        
102
        if (m_epoch.empty())
104✔
103
                *dynaml_stream << "    <Epoch/>" << std::endl;
103✔
104
        else
105
                *dynaml_stream << "    <Epoch>" << m_epoch << "</Epoch>" << std::endl;
1✔
106

107
        *dynaml_stream << "    <First>" << m_strFirst << "</First>" << std::endl;
104✔
108
        *dynaml_stream << "    <Second>" << m_strTarget << "</Second>" << std::endl;
104✔
109
        *dynaml_stream << "    <Value>" << std::fixed << std::setprecision(4) << m_dValue << "</Value>" << std::endl;
104✔
110
        *dynaml_stream << "    <StdDev>" << std::fixed << std::setprecision(6) << m_dStdDev << "</StdDev>" << std::endl;
104✔
111
        
112
        if (m_msr_db_map.is_msr_id_set)
104✔
113
                *dynaml_stream << "    <MeasurementID>" << m_msr_db_map.msr_id << "</MeasurementID>" << std::endl;
13✔
114

115
        *dynaml_stream << "  </DnaMeasurement>" << std::endl;
104✔
116
}
104✔
117

118

119
void CDnaHeightDifference::WriteDNAMsr(std::ofstream* dna_stream, const dna_msr_fields& dmw, const dna_msr_fields& dml, bool) const
96✔
120
{
121
        *dna_stream << std::setw(dmw.msr_type) << m_strType;
96✔
122
        if (m_bIgnore)
96✔
NEW
123
                *dna_stream << std::setw(dmw.msr_ignore) << "*";
×
124
        else
125
                *dna_stream << std::setw(dmw.msr_ignore) << " ";
96✔
126

127
        *dna_stream << std::left << std::setw(dmw.msr_inst) << m_strFirst;
96✔
128
        *dna_stream << std::left << std::setw(dmw.msr_targ1) << m_strTarget;
96✔
129
        *dna_stream << std::setw(dmw.msr_targ2) << " ";
96✔
130
        *dna_stream << std::right << std::setw(dmw.msr_linear) << std::fixed << std::setprecision(4) << m_dValue;        // linear measurement value
96✔
131
        *dna_stream << std::setw(dmw.msr_ang_d + dmw.msr_ang_m + dmw.msr_ang_s) << " ";
96✔
132
        
133
        UINT32 m_stdDevPrec(3); // note change from 6 decimal places to 3
96✔
134
        *dna_stream << std::setw(dmw.msr_stddev) << StringFromTW(m_dStdDev, dmw.msr_stddev, m_stdDevPrec);
192✔
135
        //*dna_stream << std::setw(dmw.msr_stddev) << std::fixed << std::setprecision(6) << m_dStdDev;
136

137
        *dna_stream << std::setw(dml.msr_gps_epoch - dml.msr_inst_ht) << " ";
96✔
138
        *dna_stream << std::setw(dmw.msr_gps_epoch) << m_epoch;
96✔
139

140
        if (m_msr_db_map.is_msr_id_set)
96✔
141
                *dna_stream << std::setw(dmw.msr_id_msr) << m_msr_db_map.msr_id;
6✔
142

143
        *dna_stream << std::endl;
96✔
144
}
96✔
145
        
146

147
void CDnaHeightDifference::SimulateMsr(vdnaStnPtr* vStations, const CDnaEllipsoid* ellipsoid)
1✔
148
{
149
        // Zn is the z coordinate element of the point on the z-axis 
150
        // which intersects with the the normal at the given Latitude
151
        double h1, h2, nu1, Zn1, nu2, Zn2;
1✔
152

153
        // calculated height
154
        m_dValue = EllipsoidHeightDifference<double>(
1✔
155
                vStations->at(m_lstn1Index).get()->GetXAxis(), 
1✔
156
                vStations->at(m_lstn1Index).get()->GetYAxis(),
1✔
157
                vStations->at(m_lstn1Index).get()->GetZAxis(),
1✔
158
                vStations->at(m_lstn2Index).get()->GetXAxis(), 
1✔
159
                vStations->at(m_lstn2Index).get()->GetYAxis(),
1✔
160
                vStations->at(m_lstn2Index).get()->GetZAxis(),
1✔
161
                vStations->at(m_lstn1Index).get()->GetcurrentLatitude(),
1✔
162
                vStations->at(m_lstn2Index).get()->GetcurrentLatitude(),
1✔
163
                &h1, &h2, &nu1, &Zn1, &nu2, &Zn2, ellipsoid);
164

165
        double distance = GreatCircleDistance<double>(
1✔
166
                vStations->at(m_lstn1Index).get()->GetcurrentLatitude(),
1✔
167
                vStations->at(m_lstn1Index).get()->GetcurrentLongitude(),
1✔
168
                vStations->at(m_lstn2Index).get()->GetcurrentLatitude(),
1✔
169
                vStations->at(m_lstn2Index).get()->GetcurrentLongitude());
1✔
170

171
        m_dStdDev = 3.0 * sqrt(distance / 1000.0) / 100.0;
1✔
172

173
        m_epoch = "01.10.1985";
1✔
174

175
        // N value available?
176
        if (fabs(vStations->at(m_lstn1Index).get()->GetgeoidSep()) > PRECISION_1E4 ||
1✔
177
                fabs(vStations->at(m_lstn2Index).get()->GetgeoidSep()) > PRECISION_1E4)
×
178
        {
179
                // reduce to orthometric height difference
180
                m_preAdjCorr = vStations->at(m_lstn2Index).get()->GetgeoidSep() - vStations->at(m_lstn1Index).get()->GetgeoidSep();
1✔
181
                m_dValue -= m_preAdjCorr;
1✔
182
        }
183

184
    // TODO - add option to perturb all measurements and standard deviations by a small (random) amount
185
        //      - Below is an example of how this might be achieved
186
    //
187
        //// perturb standard deviation
188
        //m_dStdDev = static_cast<double>(stdev(rng)) * sqrt(distance / 1000.0) / 100.0;
189
        //
190
        //// perturb measurement
191
        //double whichway = static_cast<double>(pertu(rng));
192
        //if (whichway > 0.5)
193
        //        m_dValue -= static_cast<double>(pertu(rng))/10.0;
194
        //else
195
        //        m_dValue += static_cast<double>(pertu(rng))/10.0;
196
}
1✔
197
        
198

199
UINT32 CDnaHeightDifference::SetMeasurementRec(const vstn_t& binaryStn, it_vmsr_t& it_msr, it_vdbid_t& dbidmap)
13✔
200
{
201
        m_bIgnore = it_msr->ignore;
13✔
202
        m_MSmeasurementStations = (MEASUREMENT_STATIONS)it_msr->measurementStations;
13✔
203
        
204
        m_strType = it_msr->measType;
13✔
205
        
206
        // first station
207
        m_lstn1Index = it_msr->station1;
13✔
208
        m_strFirst = binaryStn.at(it_msr->station1).stationName;
13✔
209

210
        // target station
211
        m_lstn2Index = it_msr->station2;
13✔
212
        m_strTarget = binaryStn.at(it_msr->station2).stationName;
13✔
213
        
214
        m_measAdj = it_msr->measAdj;
13✔
215
        m_measCorr = it_msr->measCorr;
13✔
216
        m_measAdjPrec = it_msr->measAdjPrec;
13✔
217
        m_residualPrec = it_msr->residualPrec;
13✔
218
        m_preAdjCorr = it_msr->preAdjCorr;
13✔
219
        m_dValue = it_msr->term1;
13✔
220
        m_dStdDev = sqrt(it_msr->term2);
13✔
221

222
        m_epoch = it_msr->epoch;
13✔
223

224
        CDnaMeasurement::SetDatabaseMap(*dbidmap);
13✔
225

226
        return 0;
13✔
227
}
228
        
229

230
void CDnaHeightDifference::WriteBinaryMsr(std::ofstream* binary_stream, PUINT32 msrIndex) const
3,461✔
231
{
232
        measurement_t measRecord;
3,461✔
233
        measRecord.measType = GetTypeC();
3,461✔
234
        measRecord.measStart = xMeas;
3,461✔
235
        measRecord.ignore = m_bIgnore;
3,461✔
236
        measRecord.station1 = m_lstn1Index;
3,461✔
237
        measRecord.station2 = m_lstn2Index;
3,461✔
238
        measRecord.measAdj = m_measAdj;
3,461✔
239
        measRecord.measCorr = m_measCorr;
3,461✔
240
        measRecord.measAdjPrec = m_measAdjPrec;
3,461✔
241
        measRecord.residualPrec = m_residualPrec;
3,461✔
242
        measRecord.preAdjCorr = m_preAdjCorr;
3,461✔
243
        measRecord.term1 = m_dValue;
3,461✔
244
        measRecord.term2 = m_dStdDev * m_dStdDev;        // convert to variance
3,461✔
245
        measRecord.measurementStations = m_MSmeasurementStations;
3,461✔
246
        measRecord.fileOrder = ((*msrIndex)++);
3,461✔
247

248
        sprintf(measRecord.epoch, "%s", m_epoch.substr(0, STN_EPOCH_WIDTH).c_str());
3,461✔
249

250
        binary_stream->write(reinterpret_cast<char *>(&measRecord), sizeof(measurement_t));
3,461✔
251
}
3,461✔
252

253

254
void CDnaHeightDifference::SetValue(const std::string& str)
3,671✔
255
{
256
        DoubleFromString(m_dValue, trimstr(str));
3,671✔
257
}
3,671✔
258

259
void CDnaHeightDifference::SetStdDev(const std::string& str)
3,671✔
260
{
261
        DoubleFromString(m_dStdDev, trimstr(str));
3,671✔
262
}
3,671✔
263

264
}        // namespace measurements
265
}        // 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