• 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

86.08
/dynadjust/include/parameters/dnadatum.cpp
1
//============================================================================
2
// Name         : dnadatum.hpp
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 Datum Library
21
//============================================================================
22

23
#include <include/parameters/dnadatum.hpp>
24
#include <include/parameters/dnaepsg.hpp>
25

26
using namespace dynadjust::epsg;
27

28
namespace dynadjust {
29
namespace datum_parameters {
30

31
// default to GDA2020
32
CDnaDatum::CDnaDatum(void)
1,952✔
33
        // "GDA2020 (3D)" - geographic
34
        : epsgCode_(DEFAULT_EPSG_U)
1,952✔
35
        , epoch_(boost::gregorian::date(2020, 1, 1))
7,808✔
36
        , datumType_(STATIC_DATUM)
1,952✔
37
        , datumName_(DEFAULT_DATUM)
3,904✔
38
{
39
        ellipsoid_.SetEllipsoid(epsgCode_);
1,952✔
40
}
1,952✔
41

42
CDnaDatum::CDnaDatum(const UINT32& epsgCode)
21,691✔
43
{
44
        // Set datum with default epoch of today
45
        SetDatum(epsgCode);
21,691✔
46
}
21,691✔
47

48
CDnaDatum::CDnaDatum(const UINT32& epsgCode, const boost::gregorian::date& epoch)
203,180✔
49
{
50
        SetDatum(epsgCode, epoch);
203,180✔
51
}
203,180✔
52

NEW
53
CDnaDatum::CDnaDatum(const std::string& epsgCode, const std::string& epoch)
×
54
{
UNCOV
55
        SetDatumFromEpsg(epsgCode, epoch);
×
UNCOV
56
}
×
57
        
58
//// datumName corresponds to the name given in epsg
59
//// epoch is a space delimited string: YYY MM DD
60
//CDnaDatum::CDnaDatum(const std::string& datumName, const std::string& epoch)
61
//{
62
//        datumName_ = datumName;
63
//        SetDatumFromName(datumName, epoch);
64
//}
65

66
//CDnaDatum::CDnaDatum(const CDnaDatum& newDatum)
67
//{
68
//        epsgCode_ = newDatum.epsgCode_;
69
//        ellipsoid_ = newDatum.ellipsoid_;
70
//        epoch_ = newDatum.epoch_;
71
//        datumType_ = newDatum.datumType_;
72
//        datumName_ = newDatum.datumName_;
73
//}
74

75
CDnaDatum& CDnaDatum::operator=(const CDnaDatum& rhs)
140,758✔
76
{
77
        if (this == &rhs)        // check for assignment to self!
140,758✔
78
                return *this;
79

80
        epsgCode_ = rhs.epsgCode_;
140,758✔
81
        ellipsoid_ = rhs.ellipsoid_;
140,758✔
82
        epoch_ = rhs.epoch_;
140,758✔
83
        datumType_ = rhs.datumType_;
140,758✔
84
        datumName_ = rhs.datumName_;
140,758✔
85

86
        return *this;
140,758✔
87
}
88

89
bool CDnaDatum::operator==(const CDnaDatum& rhs) const
79,035✔
90
{
91
        return (
79,035✔
92
                epsgCode_ == rhs.epsgCode_ &&
329✔
93
                ellipsoid_ == rhs.ellipsoid_ &&
658✔
94
                epoch_ == rhs.epoch_ &&
79,364✔
95
                datumType_ == rhs.datumType_
240✔
96
                );
79,035✔
97
}
98

99
//bool CDnaDatum::isSameFrame(const CDnaDatum& rhs) const
100
//{
101
//        return (
102
//                epsgCode_ == rhs.epsgCode_ &&
103
//                ellipsoid_ == rhs.ellipsoid_ &&
104
//                datumType_ == rhs.datumType_
105
//                );
106
//}
107

108
void CDnaDatum::initialiseDatumFromEpsgCode()
305,541✔
109
{
110
        // Initialise ellipsoid using epsg code and set epoch if static
111
        ellipsoid_.SetEllipsoid(epsgCode_);
305,541✔
112
        
113
        // datum type?
114
        if (isEpsgDatumStatic(epsgCode_))
305,541✔
115
                datumType_ = STATIC_DATUM;
13,983✔
116
        else
117
                datumType_ = DYNAMIC_DATUM;
291,558✔
118
        
119
        // Set name
120
        datumName_ = datumFromEpsgCode<std::string, UINT32>(epsgCode_);
305,541✔
121
}
305,541✔
122
        
123
// returns:
124
//  - dd.mm.yyyy for datums that have a reference epoch
125
//  - "" for ensembles that do not have an epoch
126
std::string CDnaDatum::GetEpoch_s() const
235,217✔
127
{
128
        if (isEpsgWGS84Ensemble(epsgCode_) && isTimeImmemorial(epoch_))
235,217✔
129
                return "";
×
130
        else if (isTimeImmemorial(epoch_))
235,217✔
131
                return "";
×
132
        return stringFromDate<boost::gregorian::date>(epoch_);
235,217✔
133
}
134
        
135
std::string CDnaDatum::GetEpsgCode_s() const 
206,488✔
136
{
137
        char epsgCode[8];
206,488✔
138
        sprintf(epsgCode, "%d", epsgCode_);
206,488✔
139
        return std::string(epsgCode); 
206,488✔
140
}
141

142
void CDnaDatum::SetDatum(const UINT32& epsgCode)
21,691✔
143
{
144
        epsgCode_ = epsgCode;
21,691✔
145
        epoch_ = dateFromString<boost::gregorian::date>(referenceepochFromEpsgCode(epsgCode_));
21,691✔
146

147
        // set datum parameters using epsg code
148
        initialiseDatumFromEpsgCode();
21,691✔
149
}
21,691✔
150

151
void CDnaDatum::SetDatum(const UINT32& epsgCode, const boost::gregorian::date& epoch)
203,180✔
152
{
153
        epsgCode_ = epsgCode;
203,180✔
154
        epoch_ = epoch;
203,180✔
155

156
        // set datum parameters using epsg code
157
        initialiseDatumFromEpsgCode();
203,180✔
158
}
203,180✔
159

NEW
160
void CDnaDatum::SetDatum(const std::string& epsgCode)
×
161
{
162
        // Reuse
163
        SetDatum(LongFromString<UINT32>(trimstr(epsgCode)));
×
164
}
×
165

166
//void CDnaDatum::SetDatum(const std::string& epsgCode, const boost::gregorian::date& epoch)
167
//{
168
//        // Reuse
169
//        SetDatum(LongFromString<UINT32>(trimstr(epsgCode)), epoch);
170
//}
171

172
void CDnaDatum::SetEpoch(const std::string& epoch)
80,699✔
173
{
174
        // Parse epoch
175
        if (epoch.empty())
80,699✔
176
        {
UNCOV
177
                if (isEpsgWGS84Ensemble(epsgCode_))
×
NEW
178
                        epoch_ = timeImmemorial<boost::gregorian::date>();
×
179
                else
NEW
180
                        epoch_ = dateFromString<boost::gregorian::date>(referenceepochFromEpsgCode(epsgCode_));
×
181
        }
182
        else
183
                epoch_ = dateFromString<boost::gregorian::date>(epoch);
80,699✔
184
}
80,698✔
185

186
//void CDnaDatum::SetEpoch(const double& decimal_year)
187
//{
188
//        epoch_ = dateFromDouble_doy_year<boost::gregorian::date, double>(decimal_year);
189
//
190
//}
191

192
void CDnaDatum::SetDatumFromName(const std::string& datumName, const std::string& epoch)
1,592✔
193
{
194
        // Get epsg code
195
        epsgCode_ = epsgCodeFromName<UINT32, std::string>(datumName);
1,592✔
196

197
        // Parse epoch
198
        SetEpoch(epoch);
1,591✔
199

200
        // set datum parameters using epsg code
201
        initialiseDatumFromEpsgCode();
1,590✔
202
}
1,590✔
203

204
void CDnaDatum::SetDatumFromEpsg(const std::string& epsgCode, const std::string& epoch)
79,080✔
205
{
206
        // Get epsg code
207
        epsgCode_ = LongFromString<UINT32>(trimstr(epsgCode));
79,080✔
208

209
        // Check valid epsg code (throws an exception on unknown code)
210
        validateEpsgCode(epsgCode_);
79,080✔
211

212
        // Parse epoch
213
        SetEpoch(epoch);
79,080✔
214

215
        // set datum parameters using epsg code
216
        initialiseDatumFromEpsgCode();
79,080✔
217
}
79,080✔
218

219
}        // namespace datum_parameters
220
}        // 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