• 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.0
/dynadjust/include/measurement_types/dnacoordinate.cpp
1
//============================================================================
2
// Name         : dnacoordinate.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  : CDnaCoordinate implementation file
21
//============================================================================
22

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

25
namespace dynadjust {
26
namespace measurements {
27

28
CDnaCoordinate::CDnaCoordinate(void)
128✔
29
        : m_drValue(0.)
128✔
30
        , m_dStdDev(0.)
128✔
31
{
32
        m_MSmeasurementStations = ONE_STATION;
128✔
33
}
128✔
34

35

36
CDnaCoordinate::~CDnaCoordinate(void)
152✔
37
{
38

39
}
152✔
40
        
41

42
bool CDnaCoordinate::operator== (const CDnaCoordinate& rhs) const
8✔
43
{
44
        return (
8✔
45
                m_strFirst == rhs.m_strFirst &&
16✔
46
                m_strType == rhs.m_strType &&
8✔
47
                m_bIgnore == rhs.m_bIgnore &&
8✔
48
                m_drValue == rhs.m_drValue &&
8✔
49
                m_dStdDev == rhs.m_dStdDev &&
16✔
50
                m_epoch == rhs.m_epoch
8✔
51
                );
8✔
52
}
53

54
bool CDnaCoordinate::operator< (const CDnaCoordinate& rhs) const
11✔
55
{
56
        if (m_strFirst == rhs.m_strFirst) {
11✔
57
                if (m_strType == rhs.m_strType) {        // could be P, Q, J, K
11✔
58
                        if (m_bIgnore == rhs.m_bIgnore) {
11✔
59
                                if (m_epoch == rhs.m_epoch) {
11✔
60
                                if (m_drValue == rhs.m_drValue)
11✔
61
                                        return m_dStdDev < rhs.m_dStdDev; 
11✔
62
                                else
63
                                        return m_drValue < rhs.m_drValue; }
×
64
                                else
65
                                        return m_epoch < rhs.m_epoch; }
×
66
                        else
67
                                return m_bIgnore < rhs.m_bIgnore; }
×
68
                else
69
                        return m_strType < rhs.m_strType; }
×
70
        else
71
                return m_strFirst < rhs.m_strFirst;
×
72
}
73
        
74

75
void CDnaCoordinate::WriteDynaMLMsr(std::ofstream* dynaml_stream, const std::string& comment, bool) const
56✔
76
{
77
        if (comment.empty())
56✔
78
                *dynaml_stream << "  <!-- Type " << measurement_name<char, std::string>(GetTypeC()) << " -->" << std::endl;
168✔
79
        else
NEW
80
                *dynaml_stream << "  <!-- " << comment << " -->" << std::endl;
×
81

82
        *dynaml_stream << "  <DnaMeasurement>" << std::endl;
56✔
83
        *dynaml_stream << "    <Type>" << m_strType << "</Type>" << std::endl;
56✔
84
        // Source file from which the measurement came
85
        *dynaml_stream << "    <Source>" << m_sourceFile << "</Source>" << std::endl;
56✔
86
        if (m_bIgnore)
56✔
87
                *dynaml_stream << "    <Ignore>*</Ignore>" << std::endl;
12✔
88
        else
89
                *dynaml_stream << "    <Ignore/>" << std::endl;
44✔
90

91
        if (m_epoch.empty())
56✔
92
                *dynaml_stream << "    <Epoch/>" << std::endl;
52✔
93
        else
94
                *dynaml_stream << "    <Epoch>" << m_epoch << "</Epoch>" << std::endl;
4✔
95

96
        *dynaml_stream << "    <First>" << m_strFirst << "</First>" << std::endl;
56✔
97
        
98
        *dynaml_stream << "    <Value>" << std::fixed << std::setprecision(10);
56✔
99
        switch (GetTypeC())
56✔
100
        {
101
        case 'P':
28✔
102
        case 'I':                // Latitude requires Degrees(...)
28✔
103
                *dynaml_stream << RadtoDms(m_drValue);
28✔
104
                break;
28✔
105
        case 'Q':
28✔
106
        case 'J':                // Longitude requires DegreesL(...)
28✔
107
                *dynaml_stream << RadtoDmsL(m_drValue);
28✔
108
                break;
28✔
109
        }
110

111
        *dynaml_stream << "</Value>" << std::endl;
56✔
112
        
113
        *dynaml_stream << "    <StdDev>" << std::scientific << std::setprecision(6) << Seconds(m_dStdDev) << "</StdDev>" << std::endl;
56✔
114
                
115
        if (m_msr_db_map.is_msr_id_set)
56✔
116
                *dynaml_stream << "    <MeasurementID>" << m_msr_db_map.msr_id << "</MeasurementID>" << std::endl;
52✔
117
        
118
        *dynaml_stream << "  </DnaMeasurement>" << std::endl;
56✔
119
}
56✔
120
        
121

122
void CDnaCoordinate::WriteDNAMsr(std::ofstream* dna_stream, const dna_msr_fields& dmw, const dna_msr_fields& dml, bool) const
28✔
123
{
124
        *dna_stream << std::setw(dmw.msr_type) << m_strType;
28✔
125
        if (m_bIgnore)
28✔
NEW
126
                *dna_stream << std::setw(dmw.msr_ignore) << "*";
×
127
        else
128
                *dna_stream << std::setw(dmw.msr_ignore) << " ";
28✔
129
        *dna_stream << std::left << std::setw(dmw.msr_inst) << m_strFirst;
28✔
130
        *dna_stream << std::setw(dmw.msr_targ1) << " ";        // first target
28✔
131
        *dna_stream << std::setw(dmw.msr_targ2) << " ";        // second target
28✔
132
        *dna_stream << std::right << std::setw(dmw.msr_linear) << std::fixed << std::setprecision(9) << RadtoDms(m_drValue);        // linear measurement value
28✔
133
        *dna_stream << std::setw(dmw.msr_ang_d + dmw.msr_ang_m + dmw.msr_ang_s) << " ";
28✔
134

135
        UINT32 m_stdDevPrec(6);
28✔
136
        *dna_stream << std::setw(dmw.msr_stddev) << StringFromTW(Seconds(m_dStdDev), dmw.msr_stddev, m_stdDevPrec);
56✔
137
        //*dna_stream << std::setw(dmw.msr_stddev) << std::fixed << std::setprecision(6) << Seconds(m_dStdDev);
138

139
        *dna_stream << std::setw(dml.msr_gps_epoch - dml.msr_inst_ht) << " ";
28✔
140
        *dna_stream << std::setw(dmw.msr_gps_epoch) << m_epoch;
28✔
141

142
        if (m_msr_db_map.is_msr_id_set)
28✔
143
                *dna_stream << std::setw(dmw.msr_id_msr) << m_msr_db_map.msr_id;
24✔
144

145
        *dna_stream << std::endl;
28✔
146
}
28✔
147
        
148

149
void CDnaCoordinate::SimulateMsr(vdnaStnPtr* vStations, const CDnaEllipsoid*)
4✔
150
{
151
        switch (GetTypeC())
4✔
152
        {
153
        case 'P':
2✔
154
        case 'I':
2✔
155
                m_drValue = vStations->at(m_lstn1Index).get()->GetcurrentLatitude();
2✔
156
                break;
2✔
157
        case 'Q':
2✔
158
        case 'J':
2✔
159
                m_drValue = vStations->at(m_lstn1Index).get()->GetcurrentLongitude();
2✔
160
                break;
2✔
161
        }
162

163
        switch (GetTypeC())
4✔
164
        {
165
        case 'I':
1✔
166
                // convert to astro (requires geoid)
167
                if (fabs(vStations->at(m_lstn1Index).get()->GetmeridianDef()) > E4_SEC_DEFLECTION)
1✔
168
                        m_drValue = vStations->at(m_lstn1Index).get()->GetcurrentLatitude() +
1✔
169
                                vStations->at(m_lstn1Index).get()->GetmeridianDef();
1✔
170
                break;
171
        case 'J':
1✔
172
                // convert to astro (requires geoid)
173
                if (fabs(vStations->at(m_lstn1Index).get()->GetverticalDef()) > E4_SEC_DEFLECTION)
1✔
174
                        m_drValue = vStations->at(m_lstn1Index).get()->GetcurrentLongitude() +
1✔
175
                                vStations->at(m_lstn1Index).get()->GetverticalDef() / 
1✔
176
                                cos(vStations->at(m_lstn1Index).get()->GetcurrentLatitude());
1✔
177
                break;
178
        }
179

180
        // compute standard deviation in radians
181
        m_dStdDev = SecondstoRadians(0.021);
4✔
182

183
        m_epoch = "01.10.1985";
4✔
184
}
4✔
185
        
186

187
UINT32 CDnaCoordinate::SetMeasurementRec(const vstn_t& binaryStn, it_vmsr_t& it_msr, it_vdbid_t& dbidmap)
36✔
188
{
189
        m_strType = it_msr->measType;
36✔
190
        m_bIgnore = it_msr->ignore;
36✔
191
        m_MSmeasurementStations = (MEASUREMENT_STATIONS)it_msr->measurementStations;
36✔
192
        
193
        m_lstn1Index = it_msr->station1;
36✔
194
        m_strFirst = binaryStn.at(it_msr->station1).stationName;
36✔
195
        
196
        m_measAdj = it_msr->measAdj;
36✔
197
        m_measCorr = it_msr->measCorr;
36✔
198
        m_measAdjPrec = it_msr->measAdjPrec;
36✔
199
        m_residualPrec = it_msr->residualPrec;
36✔
200
        m_preAdjCorr = it_msr->preAdjCorr;
36✔
201
        m_drValue = it_msr->term1;
36✔
202
        m_dStdDev = sqrt(it_msr->term2);
36✔
203

204
        m_epoch = it_msr->epoch;
36✔
205

206
        CDnaMeasurement::SetDatabaseMap(*dbidmap);
36✔
207

208
        return 0;
36✔
209
}
210

211
void CDnaCoordinate::WriteBinaryMsr(std::ofstream* binary_stream, PUINT32 msrIndex) const
88✔
212
{
213
        measurement_t measRecord;
88✔
214
        measRecord.measType = GetTypeC();
88✔
215
        measRecord.measStart = xMeas;
88✔
216
        measRecord.ignore = m_bIgnore;
88✔
217
        measRecord.station1 = m_lstn1Index;
88✔
218
        measRecord.measAdj = m_measAdj;
88✔
219
        measRecord.measCorr = m_measCorr;
88✔
220
        measRecord.measAdjPrec = m_measAdjPrec;
88✔
221
        measRecord.residualPrec = m_residualPrec;
88✔
222
        measRecord.preAdjCorr = m_preAdjCorr;
88✔
223
        measRecord.term1 = m_drValue;
88✔
224
        measRecord.term2 = m_dStdDev * m_dStdDev;        // convert to variance
88✔
225
        measRecord.term3 = measRecord.term4 = 0.;
88✔
226
        measRecord.measurementStations = m_MSmeasurementStations;
88✔
227
        measRecord.fileOrder = ((*msrIndex)++);
88✔
228

229
        sprintf(measRecord.epoch, "%s", m_epoch.substr(0, STN_EPOCH_WIDTH).c_str());
88✔
230

231
        binary_stream->write(reinterpret_cast<char *>(&measRecord), sizeof(measurement_t));
88✔
232
}
88✔
233

234

235
void CDnaCoordinate::SetValue(const std::string& str)
88✔
236
{
237
        RadFromDmsString(&m_drValue, trimstr(str));
88✔
238
}
88✔
239

240
void CDnaCoordinate::SetStdDev(const std::string& str)
88✔
241
{
242
        RadFromSecondsString(&m_dStdDev, trimstr(str));                        // convert to radians
88✔
243
}
88✔
244

245

246
}        // namespace measurements
247
}        // 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