Skip to content

Commit a90fbce

Browse files
authored
Merge pull request #353 from rogerfraser/1.4.0
Initial changes to support SIRGAS 95 and 2000
2 parents f348b6a + ac3e065 commit a90fbce

6 files changed

Lines changed: 216 additions & 16 deletions

File tree

dynadjust/dynadjust/dnareftran/dnareftran.cpp

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ void dna_reftran::TransformBinaryFiles(const std::string& bstFile, const std::st
8282
// Identify and apply any substitutions for WGS84 in the list of measurements
8383
ApplyMeasurementFrameSubstitutions();
8484

85-
datumTo_.SetDatumFromName(newFrame, newEpoch);
86-
8785
// 2. Transform measurements first (because pre-transformed station
8886
// coordinates are required)
8987
TransformMeasurementRecords(newFrame, newEpoch);
@@ -312,6 +310,14 @@ void dna_reftran::LoadWGS84FrameSubstitutions()
312310
frameSubstitution.reset(new WGS84_ITRF2014<std::string, UINT32, double>);
313311
_frameSubstitutions.push_back(frameSubstitution);
314312

313+
// SIRGAS95 to ITRF94
314+
frameSubstitution.reset(new SIRGAS95_ITRF94<std::string, UINT32, double>);
315+
_frameSubstitutions.push_back(frameSubstitution);
316+
317+
// SIRGAS2000 to ITRF2000
318+
frameSubstitution.reset(new SIRGAS2000_ITRF2000<std::string, UINT32, double>);
319+
_frameSubstitutions.push_back(frameSubstitution);
320+
315321
std::sort(_frameSubstitutions.begin(), _frameSubstitutions.end(),
316322
CompareSubstituteOnFrameName< frame_substitutions_t<std::string, UINT32, double>, std::string>());
317323

@@ -382,6 +388,49 @@ void dna_reftran::LogFrameSubstitutions(std::vector<string_string_pair>& substit
382388

383389
}
384390

391+
void dna_reftran::ApplyToFrameSubstitution()
392+
{
393+
std::string epsgSubstitute;
394+
395+
std::string strEpsgTo(datumTo_.GetEpsgCode_s());
396+
std::string strEpochTo(datumTo_.GetEpoch_s());
397+
398+
_v_frame_substitutions.clear();
399+
400+
try {
401+
if (IsolateandApplySubstitute(strEpsgTo, strEpochTo, epsgSubstitute))
402+
{
403+
_v_frame_substitutions.push_back(string_string_pair(
404+
datumFromEpsgString(std::string(strEpsgTo)),
405+
datumFromEpsgString(epsgSubstitute)));
406+
datumTo_.SetDatum(epsgSubstitute);
407+
datumTo_.SetEpoch(strEpochTo);
408+
}
409+
} catch (const RefTranException& e) {
410+
std::stringstream error_msg;
411+
error_msg << std::endl
412+
<< " - Target frame: " << datumFromEpsgString<std::string>(strEpsgTo) << " doesn't exist."
413+
<< std::endl;
414+
415+
switch (e.exception_type()) {
416+
case REFTRAN_WGS84_TRANS_UNSUPPORTED: {
417+
std::stringstream throw_msg;
418+
throw_msg << e.what() << error_msg.str() << std::endl;
419+
throw RefTranException(throw_msg.str(), REFTRAN_WGS84_TRANS_UNSUPPORTED);
420+
break;
421+
}
422+
default: throw RefTranException(e.what()); break;
423+
}
424+
}
425+
426+
if (_v_frame_substitutions.empty())
427+
return;
428+
if (projectSettings_.g.verbose < 2)
429+
return;
430+
431+
LogFrameSubstitutions(_v_frame_substitutions, "Frame");
432+
}
433+
385434

386435
void dna_reftran::ApplyStationFrameSubstitutions()
387436
{
@@ -1455,8 +1504,10 @@ void dna_reftran::TransformStationRecords(const std::string& newFrame, const std
14551504
#endif
14561505

14571506
try {
1458-
// 1. Get the datum (and epoch) of the desired system
1459-
datumTo_.SetDatumFromName(newFrame, newEpoch);
1507+
// 1. Get the datum (and epoch) of the desired system and apply the
1508+
// appropriate substitution (required to determine the transformation parameters)
1509+
datumTo_.SetDatumFromName(newFrame, newEpoch);
1510+
ApplyToFrameSubstitution();
14601511

14611512
// 2. For every station, get the datum, then transform
14621513
// TransformStation takes
@@ -1573,8 +1624,10 @@ void dna_reftran::TransformMeasurementRecords(const std::string& newFrame, const
15731624
#endif
15741625

15751626
try {
1576-
// 1. Get the datum (and epoch) of the desired system
1577-
datumTo_.SetDatumFromName(newFrame, newEpoch);
1627+
// 1. Get the datum (and epoch) of the desired system and apply the
1628+
// appropriate substitution (required to determine the transformation parameters)
1629+
datumTo_.SetDatumFromName(newFrame, newEpoch);
1630+
ApplyToFrameSubstitution();
15781631

15791632
// 2. For every measurement, get the datum, determine parameters, then transform
15801633
for (msr_it=bmsBinaryRecords_.begin(); msr_it!=bmsBinaryRecords_.end(); ++msr_it)

dynadjust/dynadjust/dnareftran/dnareftran.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class dna_reftran {
197197
void LogFrameSubstitutions(std::vector<string_string_pair>& substitutions, const std::string& type);
198198
void ApplyStationFrameSubstitutions();
199199
void ApplyMeasurementFrameSubstitutions();
200+
void ApplyToFrameSubstitution();
200201

201202
bool IsolateandApplySubstitute(const std::string& epsgCode, const std::string& epoch, std::string& epsgSubstitute);
202203

@@ -224,8 +225,9 @@ class dna_reftran {
224225
v_plate_motion_cartesians plate_motion_cartesians_; // Helmert parameters computed from Euler parameters
225226

226227
vframeSubsPtr _frameSubstitutions; // Reference frame substitutions
227-
std::vector<string_string_pair> _v_stn_substitutions; // station substitutions made
228-
std::vector<string_string_pair> _v_msr_substitutions; // station substitutions made
228+
std::vector<string_string_pair> _v_stn_substitutions; // station substitutions made
229+
std::vector<string_string_pair> _v_msr_substitutions; // station substitutions made
230+
std::vector<string_string_pair> _v_frame_substitutions; // frameTo substitution made
229231

230232
v_string_uint32_pair vplateMap_; // Plate Map index sorted on plate ID
231233

dynadjust/include/parameters/dnaconsts-datums.hpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,15 @@ const UINT16 NAD83_CSRS_V6_i_xyz = 8250; // XYZ
104104
const UINT16 NAD83_CSRS_V7_i = 8254; //LatLonEht
105105
const UINT16 NAD83_CSRS_V7_i_xyz = 8253; // XYZ
106106
const UINT16 NAD83_CSRS_V8_i = 10413; // LatLonEht
107-
const UINT16 NAD83_CSRS_V8_i_xyz = 10412; // XYZ
108-
107+
const UINT16 NAD83_CSRS_V8_i_xyz = 10412; // XYZ
109108

109+
const UINT16 YACARE_ROUUSAMS_i = 4309; // LatLon (2D) only
110+
const UINT16 SIRGAS_ROU98_i_xyz = 5379; // XYZ
111+
const UINT16 SIRGAS_ROU98_i = 5380; // LatLonEht
112+
const UINT16 SIRGAS_1995_i_xyz = 4974; // XYZ
113+
const UINT16 SIRGAS_1995_i = 4975; // LatLonEht
114+
const UINT16 SIRGAS_2000_i_xyz = 4988; // XYZ
115+
const UINT16 SIRGAS_2000_i = 4989; // LatLonEht
110116

111117
const char* const AGD66_c = "4202";
112118
const char* const AGD84_c = "4203";
@@ -154,7 +160,13 @@ const char* const NAD83_CSRS_v6_c = "8250";
154160
const char* const NAD83_CSRS_v7_c = "8253";
155161
const char* const NAD83_CSRS_v8_c = "10412";
156162

157-
const char* const AGD66_epoch = "01.01.1966";
163+
const char* const YACARE_ROUUSAMS_c = "4309";
164+
// epsg strings for SIRGAS provide XYZ definition only
165+
const char* const SIRGAS_ROU98_c = "5379";
166+
const char* const SIRGAS_1995_c = "4974";
167+
const char* const SIRGAS_2000_c = "4988";
168+
169+
const char* const AGD66_epoch = "01.01.1966";
158170
const char* const AGD84_epoch = "01.01.1984";
159171
const char* const GDA94_epoch = "01.01.1994";
160172
const char* const GDA2020_epoch = "01.01.2020";
@@ -193,6 +205,11 @@ const char* const NAD83_CSRS_V6_epoch = "01.01.2010";
193205
const char* const NAD83_CSRS_V7_epoch = "01.01.2010";
194206
const char* const NAD83_CSRS_V8_epoch = "01.01.2010";
195207

208+
const char* const YACARE_ROUUSAMS_epoch = "01.01.1963"; // Yacare ROU by U.S. Army Map Service was established in 1963.
209+
const char* const SIRGAS_ROU98_epoch = "03.07.1995"; // 1995.5
210+
const char* const SIRGAS_1995_epoch = "01.04.1995"; // 1995.4
211+
const char* const SIRGAS_2000_epoch = "01.04.2000"; // 2000.4
212+
196213
const char* const AGD66_s = "AGD66";
197214
const char* const AGD84_s = "AGD84";
198215
const char* const GDA94_s = "GDA94";
@@ -280,5 +297,15 @@ const char* const NAD83_CSRS_V8_alias1_s = "NAD83 (CSRS) v8";
280297
const char* const NAD83_CSRS_V8_alias2_s = "NAD83(CSRS)V8";
281298
const char* const NAD83_CSRS_V8_alias3_s = "NAD83 (CSRS) V8";
282299

300+
const char* const YACARE_ROUUSAMS_s = "YACARE ROUUSAMS"; // Yacare ROU by U.S. Army Map Service was established in 1963.
301+
const char* const YACARE_ROUUSAMS_alias_s = "YACARE-ROUUSAMS";
302+
const char* const SIRGAS_ROU98_s = "SIRGAS ROU98";
303+
const char* const SIRGAS_ROU98_alias_s = "SIRGAS-ROU98";
304+
const char* const SIRGAS_1995_s = "SIRGAS95";
305+
const char* const SIRGAS_1995_alias1_s = "SIRGAS 95";
306+
const char* const SIRGAS_1995_alias2_s = "SIRGAS 1995";
307+
const char* const SIRGAS_2000_s = "SIRGAS2000";
308+
const char* const SIRGAS_2000_alias_s = "SIRGAS 2000";
309+
283310

284311
#endif // DNACONSTS_DATUMS_HPP

dynadjust/include/parameters/dnadatumprojectionparam.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@
3535
#include <include/config/dnatypes-fwd.hpp>
3636

3737
// GRS80 parameters
38-
const double GRS80_a = 6378137.0; // Semi major axis (a)
39-
const double GRS80_inv_f = 298.257222101; // Inverse flattening (1/f)
38+
const double GRS80_a = 6378137.0; // Semi major axis (a)
39+
const double GRS80_inv_f = 298.257222101; // Inverse flattening (1/f)
4040

4141
// WGS84 parameters
42-
const double WGS84_a = 6378137.0; // Semi major axis (a)
43-
const double WGS84_inv_f = 298.25722360; // Inverse flattening (1/f)
42+
const double WGS84_a = 6378137.0; // Semi major axis (a)
43+
const double WGS84_inv_f = 298.25722360; // Inverse flattening (1/f)
4444

4545
// ANS parameters
4646
const double ANS_a = 6378160.0; // Semi major axis (a)
47-
const double ANS_inv_f = 298.25; // Inverse flattening (1/f)
47+
const double ANS_inv_f = 298.25; // Inverse flattening (1/f)
48+
49+
// International 1924 parameters
50+
const double International24_a = 6378388.0; // Semi major axis (a)
51+
const double International24_inv_f = 297.0; // Inverse flattening (1/f)
4852

4953
// UTM parameters
5054
const double FALSE_E = 500000.0; // False Easting

dynadjust/include/parameters/dnaepsg.hpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,19 @@ U epsgCodeFromName(const S& datumName)
218218
iequals(datumName, NAD83_CSRS_V8_alias2_s) ||
219219
iequals(datumName, NAD83_CSRS_V8_alias3_s))
220220
return NAD83_CSRS_V8_i_xyz;
221+
// SIRGAS
222+
if (iequals(datumName, YACARE_ROUUSAMS_s))
223+
return YACARE_ROUUSAMS_i;
224+
if (iequals(datumName, SIRGAS_ROU98_s) ||
225+
iequals(datumName, SIRGAS_ROU98_alias_s))
226+
return SIRGAS_ROU98_i_xyz;
227+
if (iequals(datumName, SIRGAS_1995_s) ||
228+
iequals(datumName, SIRGAS_1995_alias1_s) ||
229+
iequals(datumName, SIRGAS_1995_alias2_s))
230+
return SIRGAS_1995_i_xyz;
231+
if (iequals(datumName, SIRGAS_2000_s) ||
232+
iequals(datumName, SIRGAS_2000_alias_s))
233+
return SIRGAS_2000_i_xyz;
221234

222235
std::stringstream ss;
223236
ss << " epsgCodeFromName: '" << datumName << "' is not a supported reference frame label." << std::endl;
@@ -341,6 +354,18 @@ S epsgStringFromName(const S& datumName)
341354
case NAD83_CSRS_V8_i:
342355
case NAD83_CSRS_V8_i_xyz:
343356
return NAD83_CSRS_v8_c;
357+
// SIRGAS
358+
case YACARE_ROUUSAMS_i:
359+
return YACARE_ROUUSAMS_c;
360+
case SIRGAS_ROU98_i:
361+
case SIRGAS_ROU98_i_xyz:
362+
return SIRGAS_ROU98_c;
363+
case SIRGAS_1995_i:
364+
case SIRGAS_1995_i_xyz:
365+
return SIRGAS_1995_c;
366+
case SIRGAS_2000_i:
367+
case SIRGAS_2000_i_xyz:
368+
return SIRGAS_2000_c;
344369
}
345370

346371
std::stringstream ss;
@@ -388,6 +413,14 @@ bool isEpsgDatumStatic(const U& epsgCode)
388413
case NAD83_CSRS_V7_i_xyz:
389414
case NAD83_CSRS_V8_i:
390415
case NAD83_CSRS_V8_i_xyz:
416+
//SIRGAS
417+
case YACARE_ROUUSAMS_i:
418+
case SIRGAS_ROU98_i:
419+
case SIRGAS_ROU98_i_xyz:
420+
case SIRGAS_1995_i:
421+
case SIRGAS_1995_i_xyz:
422+
case SIRGAS_2000_i:
423+
case SIRGAS_2000_i_xyz:
391424
return true;
392425
// ITRF....
393426
case ITRF1988_i_xyz:
@@ -516,6 +549,13 @@ void spheroidFromEpsgCode(const U& epsgCode, epsg_spheroid& ellipsoid)
516549
case NAD83_CSRS_V7_i:
517550
case NAD83_CSRS_V8_i_xyz:
518551
case NAD83_CSRS_V8_i:
552+
// SIRGAS
553+
case SIRGAS_ROU98_i: // Note: epsg.org has incorrectly assigned WGS 84 ellipsoid to SIRGAS ROU98
554+
case SIRGAS_ROU98_i_xyz:
555+
case SIRGAS_1995_i:
556+
case SIRGAS_1995_i_xyz:
557+
case SIRGAS_2000_i:
558+
case SIRGAS_2000_i_xyz:
519559
// authority
520560
ellipsoid.authority_.first = "EPSG";
521561
ellipsoid.authority_.second = "7019";
@@ -524,6 +564,16 @@ void spheroidFromEpsgCode(const U& epsgCode, epsg_spheroid& ellipsoid)
524564
ellipsoid.name_ = "GRS 1980";
525565
ellipsoid.semi_major_ = GRS80_a;
526566
break;
567+
// SIRGAS (OLD)
568+
case YACARE_ROUUSAMS_i:
569+
// authority
570+
ellipsoid.authority_.first = "EPSG";
571+
ellipsoid.authority_.second = "7022";
572+
// ellipsoid params
573+
ellipsoid.inv_flattening_ = International24_inv_f;
574+
ellipsoid.name_ = "International 1924";
575+
ellipsoid.semi_major_ = International24_a;
576+
break;
527577
// WGS84
528578
case WGS84_transit_i:
529579
case WGS84_transit_i_xyz:
@@ -670,6 +720,18 @@ std::string referenceepochFromEpsgCode(const U& epsgCode)
670720
case NAD83_CSRS_V8_i_xyz:
671721
case NAD83_CSRS_V8_i:
672722
return NAD83_CSRS_V8_epoch;
723+
// SIRGAS
724+
case YACARE_ROUUSAMS_i:
725+
return YACARE_ROUUSAMS_epoch;
726+
case SIRGAS_ROU98_i:
727+
case SIRGAS_ROU98_i_xyz:
728+
return SIRGAS_ROU98_epoch;
729+
case SIRGAS_1995_i:
730+
case SIRGAS_1995_i_xyz:
731+
return SIRGAS_1995_epoch;
732+
case SIRGAS_2000_i:
733+
case SIRGAS_2000_i_xyz:
734+
return SIRGAS_2000_epoch;
673735
default:
674736
std::stringstream ss;
675737
ss << " referenceepochFromEpsgCode: EPSG code '" << epsgCode << "' is not a supported EPSG code." << std::endl;
@@ -799,6 +861,17 @@ S datumFromEpsgCode(const U& epsgCode)
799861
case NAD83_CSRS_V8_i_xyz:
800862
case NAD83_CSRS_V8_i:
801863
return NAD83_CSRS_V8_s;
864+
case YACARE_ROUUSAMS_i:
865+
return YACARE_ROUUSAMS_s;
866+
case SIRGAS_ROU98_i_xyz:
867+
case SIRGAS_ROU98_i:
868+
return SIRGAS_ROU98_s;
869+
case SIRGAS_1995_i_xyz:
870+
case SIRGAS_1995_i:
871+
return SIRGAS_1995_s;
872+
case SIRGAS_2000_i_xyz:
873+
case SIRGAS_2000_i:
874+
return SIRGAS_2000_s;
802875
default:
803876
std::stringstream ss;
804877
ss << " datumFromEpsgCode: EPSG code '" << epsgCode << "' is not a supported EPSG code." << std::endl;
@@ -908,6 +981,14 @@ bool validateEpsgCode(const U& epsgCode)
908981
case NAD83_CSRS_V7_i:
909982
case NAD83_CSRS_V8_i_xyz:
910983
case NAD83_CSRS_V8_i:
984+
// SIRGAS
985+
case YACARE_ROUUSAMS_i:
986+
case SIRGAS_ROU98_i_xyz:
987+
case SIRGAS_ROU98_i:
988+
case SIRGAS_1995_i_xyz:
989+
case SIRGAS_1995_i:
990+
case SIRGAS_2000_i_xyz:
991+
case SIRGAS_2000_i:
911992
return true;
912993
default:
913994
std::stringstream ss;

dynadjust/include/parameters/dnaframesubstitutions.hpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,39 @@ class WGS84_ITRF2014 : public frame_substitutions_t<T1, T2, T3>
381381
virtual ~WGS84_ITRF2014() {}
382382
};
383383

384+
// SIRGAS95 to ITRF94
385+
template <class T1 = std::string, class T2 = UINT32, class T3 = double>
386+
class SIRGAS95_ITRF94 : public frame_substitutions_t<T1, T2, T3> {
387+
public:
388+
SIRGAS95_ITRF94() {
389+
frame_substitutions::frame_name = SIRGAS_1995_s;
390+
frame_substitutions::frame_epsg = SIRGAS_1995_i_xyz;
391+
frame_substitutions::frame_desc = "";
392+
frame_substitutions::substitute_name = ITRF1994_s;
393+
frame_substitutions::substitute_epsg = ITRF1994_i_xyz;
394+
395+
frame_substitutions::from_epoch = dateFromString<boost::gregorian::date>("01.01.1900");
396+
frame_substitutions::to_epoch = boost::gregorian::day_clock::local_day() + boost::gregorian::years(100);
397+
};
398+
virtual ~SIRGAS95_ITRF94() {}
399+
};
400+
401+
// SIRGAS2000 to ITRF2000
402+
template <class T1 = std::string, class T2 = UINT32, class T3 = double>
403+
class SIRGAS2000_ITRF2000 : public frame_substitutions_t<T1, T2, T3> {
404+
public:
405+
SIRGAS2000_ITRF2000() {
406+
frame_substitutions::frame_name = SIRGAS_2000_s;
407+
frame_substitutions::frame_epsg = SIRGAS_2000_i_xyz;
408+
frame_substitutions::frame_desc = "";
409+
frame_substitutions::substitute_name = ITRF2000_s;
410+
frame_substitutions::substitute_epsg = ITRF2000_i_xyz;
411+
412+
frame_substitutions::from_epoch = dateFromString<boost::gregorian::date>("01.01.1900");
413+
frame_substitutions::to_epoch = boost::gregorian::day_clock::local_day() + boost::gregorian::years(100);
414+
};
415+
virtual ~SIRGAS2000_ITRF2000() {}
416+
};
384417

385418
// FUNCTIONS
386419

0 commit comments

Comments
 (0)