• 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

73.68
/dynadjust/include/config/dnaprojectfile.cpp
1
//============================================================================
2
// Name         : dnaprojectfile.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  : DynAdjust Project class
21
//============================================================================
22

23
#include <include/config/dnatypes-gui.hpp>
24
#include <include/config/dnaprojectfile.hpp>
25
#include <include/functions/dnaiostreamfuncs.hpp>
26
#include <include/functions/dnatemplatefuncs.hpp>
27
#include <include/functions/dnastringfuncs.hpp>
28
#include <include/functions/dnafilepathfuncs.hpp>
29
#include <include/config/dnaoptions-helper.hpp>
30

31
namespace dynadjust {
32

33
CDnaProjectFile::CDnaProjectFile(void)
585✔
34
{
35
        
36
}
585✔
37

38
// Create instance and initialise settings based on context
39
CDnaProjectFile::CDnaProjectFile(const std::string& projectFile, const UINT16& verifyContext)
93✔
40
{
41
        LoadProjectFile(projectFile);
93✔
42

43
        switch (verifyContext)
93✔
44
        {
45
        case importSetting:
25✔
46
                InitialiseImportSettings();
25✔
47
                break;
48
        case reftranSetting:
42✔
49
                InitialiseReftranSettings();
42✔
50
                break;
51
        case geoidSetting:
24✔
52
                InitialiseGeoidSettings();
24✔
53
                break;
54
        case segmentSetting:
1✔
55
                InitialiseSegmentSettings();
1✔
56
                break;
57
        case adjustSetting:
1✔
58
                InitialiseAdjustSettings();
1✔
59
                break;
60
        default:
×
61
                InitialiseGeneralSettings();
×
62
        }
63
}
93✔
64

65

66
//CDnaProjectFile::CDnaProjectFile(const project_settings& project)
67
//        : settings_(project)
68
//{
69
//}
70

71
//CDnaProjectFile::CDnaProjectFile(const CDnaProjectFile& newProject)
72
//        : settings_(newProject.settings_)
73
//{        
74
//}
75

76
//CDnaProjectFile& CDnaProjectFile::operator=(const CDnaProjectFile& rhs)
77
//{
78
//        if (this == &rhs)        // check for assignment to self!
79
//                return *this;
80
//
81
//        settings_ = rhs.settings_;
82
//
83
//        return *this;
84
//}
85

86
//bool CDnaProjectFile::operator==(const CDnaProjectFile& rhs) const
87
//{
88
//        return (settings_ == rhs.settings_);
89
//}
90
        
91

92
void CDnaProjectFile::LoadProjectFile(const std::string& projectFile)
629✔
93
{
94
        // load project file
95
        if (boost::filesystem::exists(projectFile))
1,258✔
96
        {
97
                settings_.g.project_file = projectFile;
629✔
98
                LoadProjectFile();
629✔
99
        }
100
        else
101
        {
NEW
102
                std::stringstream err_msg;
×
103
                err_msg << "LoadProjectFile(): Project file " << 
×
NEW
104
                projectFile << " does not exist." << std::endl;        
×
NEW
105
                throw boost::enable_current_exception(std::runtime_error(err_msg.str()));
×
UNCOV
106
        }
×
107
}
629✔
108

109

110
void CDnaProjectFile::LoadProjectFile()
629✔
111
{
112
        // load project file using p.g.project_file
113
        std::ifstream dnaproj_file;
629✔
114

115
        std::stringstream err_msg;
629✔
116
        err_msg << "LoadProjectFile(): An error was encountered when opening " << 
629✔
117
                settings_.g.project_file << "." << std::endl;
629✔
118

119
        try {
629✔
120
                // create binary aml file.  Throws runtime_error on failure.
121
                file_opener(dnaproj_file, settings_.g.project_file,
629✔
122
                        std::ios::in, ascii, true);
123
        }
NEW
124
        catch (const std::runtime_error& e) {
×
125
                err_msg << e.what();
×
NEW
126
                throw boost::enable_current_exception(std::runtime_error(err_msg.str()));
×
127
        }
×
128
        catch (...) {
×
NEW
129
                throw boost::enable_current_exception(std::runtime_error(err_msg.str()));
×
130
        }
×
131

132
        err_msg.str("");
1,887✔
133
        err_msg << "LoadProjectFile(): An error was encountered when loading from " << 
629✔
134
                settings_.g.project_file << "." << std::endl;
629✔
135

136
        std::string str, line, var, val;
629✔
137
        std::stringstream ss;
629✔
138

139
        settingMode mSetting(unknownSetting);
140
        
141
        while (!dnaproj_file.eof())
85,576✔
142
        {
143
                try {
85,576✔
144
                        getline(dnaproj_file, line, '\n');
85,576✔
145
                }
146
                catch (std::ifstream::failure& f)
629✔
147
                {
148
                        if (dnaproj_file.eof())
629✔
149
                                break;
150
                        
NEW
151
                        err_msg << f.what() << std::endl;
×
NEW
152
                        throw boost::enable_current_exception(std::runtime_error(err_msg.str()));
×
153
                }
629✔
154
                catch (...)
×
155
                {
156
                        if (dnaproj_file.eof())
×
157
                                break;
158

NEW
159
                        err_msg << "Could not read file." << std::endl;
×
NEW
160
                        throw boost::enable_current_exception(std::runtime_error(err_msg.str()));
×
UNCOV
161
                }
×
162

163

164
                // Blank line?
165
                if (line.empty())
84,947✔
166
                        continue;
5,661✔
167

168
                // Line too short?
169
                if (line.length() <= PRINT_VAR_PAD)
79,286✔
170
                        continue;
1✔
171

172
                // #variables
173
                if (line.find(section_variables) != std::string::npos)
79,285✔
174
                {
175
                        mSetting = switchSetting;
×
176
                        continue;
×
177
                }
178

179
                // #general
180
                if (line.find(section_general) != std::string::npos)
79,285✔
181
                {
182
                        mSetting = generalSetting;
629✔
183
                        continue;
629✔
184
                }
185

186
                // #import
187
                if (line.find(section_import) != std::string::npos)
78,656✔
188
                {
189
                        mSetting = importSetting;
629✔
190
                        continue;
629✔
191
                }
192

193
                // #reftran
194
                if (line.find(section_reftran) != std::string::npos)
78,027✔
195
                {
196
                        mSetting = reftranSetting;
629✔
197
                        continue;
629✔
198
                }
199

200
                // #general
201
                if (line.find(section_geoid) != std::string::npos)
77,398✔
202
                {
203
                        mSetting = geoidSetting;
629✔
204
                        continue;
629✔
205
                }
206

207
                // #segment
208
                if (line.find(section_segment) != std::string::npos)
76,769✔
209
                {
210
                        mSetting = segmentSetting;
629✔
211
                        continue;
629✔
212
                }
213

214
                // #adjust
215
                if (line.find(section_adjust) != std::string::npos)
76,140✔
216
                {
217
                        mSetting = adjustSetting;
629✔
218
                        continue;
629✔
219
                }
220

221
                // #output
222
                if (line.find(section_output) != std::string::npos)
75,511✔
223
                {
224
                        mSetting = outputSetting;
629✔
225
                        continue;
629✔
226
                }
227

228
                // #plot
229
                if (line.find(section_plot) != std::string::npos)
74,882✔
230
                {
231
                        mSetting = plotSetting;
629✔
232
                        continue;
629✔
233
                }
234

235
                // #display
236
                if (line.find(section_display) != std::string::npos)
74,253✔
237
                {
238
                        mSetting = displaySetting;
×
239
                        continue;
×
240
                }
241
                
242
                // Line?
243
                if (line.find("----------") != std::string::npos)
74,253✔
244
                        continue;
5,032✔
245

246
                // Now get the variables and their value relating to the setting
247
                var = trimstr(line.substr(0, PRINT_VAR_PAD));
138,442✔
248
                if (line.length() > PRINT_VAR_PAD)
69,221✔
249
                        val = trimstr(line.substr(PRINT_VAR_PAD));
207,663✔
250
                else
251
                        val.clear();
×
252

253
                try {
69,221✔
254
                        switch (mSetting)
69,221✔
255
                        {
256
                        case generalSetting:
4,403✔
257
                                LoadSettingGeneral(mSetting, var, val);
4,403✔
258
                                break;
259
                        case importSetting:
24,567✔
260
                                LoadSettingImport(mSetting, var, val);
24,567✔
261
                                break;
262
                        case reftranSetting:
3,142✔
263
                                LoadSettingReftran(var, val);
3,142✔
264
                                break;
265
                        case geoidSetting:
3,146✔
266
                                LoadSettingGeoid(var, val);
3,146✔
267
                                break;
268
                        case segmentSetting:
3,774✔
269
                                LoadSettingSegment(var, val);
3,774✔
270
                                break;
271
                        case adjustSetting:
10,062✔
272
                                LoadSettingAdjust(var, val);
10,062✔
273
                                LoadSettingOutput(var, val);
10,062✔
274
                                break;
275
                        case outputSetting:
19,499✔
276
                                LoadSettingOutput(var, val);
19,499✔
277
                                break;
278
                        case plotSetting:
×
279
                                LoadSettingOutput(var, val);
×
280
                                break;
281
                        case displaySetting:
282
                                break;
283
                        default:
284
                                  break;
285
                        }
286
                }
NEW
287
                catch (const std::runtime_error& e) {
×
288
                        err_msg << e.what();
×
NEW
289
                        throw boost::enable_current_exception(std::runtime_error(err_msg.str()));
×
290
                }
×
291
                catch (...) {
×
NEW
292
                        throw boost::enable_current_exception(std::runtime_error(err_msg.str()));
×
293
                }
×
294
        }
295

296
        dnaproj_file.clear();
629✔
297
        dnaproj_file.close();
629✔
298
}
3,145✔
299

300
void CDnaProjectFile::InitialiseGeneralSettings()
93✔
301
{
302
        if (settings_.g.network_name.empty())
93✔
303
        {
NEW
304
                std::stringstream ss;
×
NEW
305
                ss << "The project file does not provide the network name. " << std::endl << std::endl;
×
NEW
306
                throw boost::enable_current_exception(std::runtime_error(ss.str()));
×
UNCOV
307
        }
×
308
}
93✔
309

310
void CDnaProjectFile::InitialiseImportSettings()
25✔
311
{
312
        InitialiseGeneralSettings();
25✔
313

314
        if (settings_.i.input_files.empty() && 
25✔
315
                settings_.i.seg_file.empty())
1✔
316
        {
317
                std::stringstream ss;
1✔
318
                ss << "Nothing to do - the project file does not list any files to import. " << std::endl << std::endl;
1✔
319
                throw boost::enable_current_exception(std::runtime_error(ss.str()));
3✔
320
        }
1✔
321

322
        std::string firstPart(settings_.g.output_folder + FOLDER_SLASH + settings_.g.network_name + ".");
72✔
323
        
324
        if (!settings_.i.bst_file.empty())
24✔
325
        {
NEW
326
                if (!boost::filesystem::exists(settings_.i.bst_file))
×
327
                        // Does the file exist?  No.  
328
                        // Assume it is a filename contained in the input folder.
329
                        // import will throw an exception if it cannot be found.
NEW
330
                        settings_.i.bst_file = formPath<std::string>(settings_.g.input_folder, 
×
NEW
331
                                leafStr<std::string>(settings_.i.bst_file));
×
332
        }
333
        else
334
                settings_.i.bst_file = firstPart + "bst";        // binary stations file
48✔
335

336
        if (!settings_.i.bms_file.empty())
24✔
337
        {
NEW
338
                if (!boost::filesystem::exists(settings_.i.bms_file))
×
339
                        // Does the file exist?  No.  
340
                        // Assume it is a filename contained in the input folder.
341
                        // import will throw an exception if it cannot be found.
NEW
342
                        settings_.i.bms_file = formPath<std::string>(settings_.g.input_folder, 
×
NEW
343
                                leafStr<std::string>(settings_.i.bms_file));
×
344
        }
345
        else
346
                settings_.i.bms_file = firstPart + "bms";        // binary measurements file
48✔
347

348
        settings_.i.asl_file = firstPart + "asl";        // associated stations list
24✔
349
        settings_.i.aml_file = firstPart + "aml";        // associated measurements list
24✔
350
        settings_.i.map_file = firstPart + "map";        // station names map
24✔
351
        settings_.i.dst_file = firstPart + "dst";        // fuplicate stations
24✔
352
        settings_.i.dms_file = firstPart + "dms";        // duplicate measurements
24✔
353
        settings_.i.imp_file = firstPart + "imp";        // log
24✔
354

355
        if (settings_.o._msr_to_stn == 1)
24✔
356
                settings_.o._m2s_file = firstPart + "m2s";        // measurement to stations table
6✔
357

358
        if (!settings_.i.seg_file.empty())
24✔
359
        {
NEW
360
                if (!boost::filesystem::exists(settings_.i.seg_file))
×
361
                        // Does the file exist?  No.  
362
                        // Assume it is a filename contained in the input folder.
363
                        // import will throw an exception if it cannot be found.
NEW
364
                        settings_.i.seg_file = formPath<std::string>(settings_.g.input_folder, 
×
NEW
365
                                leafStr<std::string>(settings_.i.seg_file));
×
366
        }
367

368
        //////////////////////////////////////////////////////////////////////////////
369
        // GNSS scaling
370
        if (fabs(settings_.i.pscale - 1.0) > PRECISION_1E5 ||
48✔
371
                fabs(settings_.i.lscale - 1.0) > PRECISION_1E5 ||
24✔
372
                fabs(settings_.i.hscale - 1.0) > PRECISION_1E5 ||
24✔
373
                fabs(settings_.i.vscale - 1.0) > PRECISION_1E5 ||
48✔
374
                !settings_.i.scalar_file.empty())
24✔
375
                settings_.i.apply_scaling = 1;
×
376
        
377
        if (!settings_.i.scalar_file.empty())
24✔
378
        {
NEW
379
                if (!boost::filesystem::exists(settings_.i.scalar_file))                        
×
380
                        // Does the file exist?  No.  
381
                        // Assume it is a filename contained in the input folder.
382
                        // import will throw an exception if it cannot be found.
NEW
383
                        settings_.i.scalar_file = formPath<std::string>(settings_.g.input_folder, 
×
NEW
384
                                leafStr<std::string>(settings_.i.scalar_file));        
×
385
        }
386

387
        // Create file name based on the provided block
388
        std::string fileName(settings_.g.network_name);
24✔
389
        if (settings_.i.import_block)
24✔
390
        {
NEW
391
                std::stringstream blk("");
×
UNCOV
392
                blk << ".block-" << settings_.i.import_block_number;
×
UNCOV
393
                fileName += blk.str();
×
UNCOV
394
        }
×
395

396
        if (settings_.i.export_dynaml)
24✔
397
        {
398
                if (settings_.i.export_single_xml_file)
7✔
399
                        settings_.i.xml_outfile = formPath<std::string>(settings_.g.output_folder, 
15✔
400
                                fileName, "xml");
5✔
401
                else
402
                {
403
                        settings_.i.xml_stnfile = formPath<std::string>(settings_.g.output_folder, 
8✔
404
                                fileName + "stn", "xml");
6✔
405
                        settings_.i.xml_msrfile = formPath<std::string>(settings_.g.output_folder, 
8✔
406
                                fileName + "msr", "xml");
6✔
407
                }
408
        }
409

410
        if (settings_.i.export_dna_files)
24✔
411
        {
412
                settings_.i.dna_stnfile = formPath<std::string>(settings_.g.output_folder, 
21✔
413
                        fileName, "stn");
7✔
414
                settings_.i.dna_msrfile = formPath<std::string>(settings_.g.output_folder, 
21✔
415
                        fileName, "msr");                
7✔
416
        }
417

418
        if (settings_.i.simulate_measurements)
24✔
NEW
419
                settings_.i.simulate_msrfile = formPath<std::string>(settings_.g.output_folder, 
×
420
                        settings_.g.network_name, "simulated.msr");
×
421

422
}
48✔
423

424
void CDnaProjectFile::InitialiseReftranSettings()
42✔
425
{
426
        InitialiseGeneralSettings();
42✔
427

428
        if (settings_.r.reference_frame.empty())
42✔
429
        {
NEW
430
                std::stringstream ss;
×
NEW
431
                ss << "Nothing to do - the project file does not specify a reference frame." << std::endl << std::endl;
×
NEW
432
                throw boost::enable_current_exception(std::runtime_error(ss.str()));
×
UNCOV
433
        }
×
434

435
        std::string firstPart(settings_.g.output_folder + FOLDER_SLASH + settings_.g.network_name + ".");
126✔
436
        settings_.r.bst_file = firstPart + "bst";        // binary stations file
42✔
437
        settings_.r.bms_file = firstPart + "bms";        // binary measurements file
42✔
438
        settings_.r.rft_file = firstPart + "rft";        // log
42✔
439

440
        if (settings_.i.export_dynaml == 1)
42✔
441
        {
442
                if (settings_.i.export_single_xml_file == 1)
8✔
443
                        settings_.i.xml_outfile = firstPart + "xml";                // single XML file
10✔
444
                else
445
                {
446
                        settings_.i.xml_stnfile = formPath<std::string>(settings_.g.output_folder,
12✔
447
                                settings_.g.network_name + "stn", "xml");
9✔
448
                        settings_.i.xml_msrfile = formPath<std::string>(settings_.g.output_folder,
12✔
449
                                settings_.g.network_name + "msr", "xml");;
9✔
450
                }
451
        }
452

453
        if (settings_.i.export_dna_files == 1)
42✔
454
        {
455
                settings_.i.dna_stnfile = firstPart + "stn";        // station file
8✔
456
                settings_.i.dna_msrfile = firstPart + "msr";        // measurement file
16✔
457
        }
458
        
459
        if (settings_.o._export_snx_file == 1)
42✔
460
                settings_.o._snx_file = firstPart + "snx";                // SINEX file
×
461

462
}
42✔
463

464
void CDnaProjectFile::InitialiseGeoidSettings()
24✔
465
{
466
        InitialiseGeneralSettings();
24✔
467

468
        // Expected behaviour: when running geoid using a project file, network name must exist
469
        if (settings_.g.network_name.empty())
24✔
470
        {
NEW
471
                std::stringstream ss;
×
NEW
472
                ss << "Nothing to do - the project file does not provide a network name. " << std::endl << std::endl;
×
NEW
473
                throw boost::enable_current_exception(std::runtime_error(ss.str()));
×
UNCOV
474
        }
×
475
        
476
        settings_.n.bst_file = formPath<std::string>(settings_.g.input_folder, settings_.g.network_name, "bst");                // binary stations file
72✔
477
        settings_.n.geo_file = formPath<std::string>(settings_.g.output_folder, settings_.g.network_name, "geo");        // dna geo file
72✔
478
        settings_.n.file_mode = 1;
24✔
479

480
        if (settings_.n.ntv2_geoid_file.empty())
24✔
481
        {
482
                std::stringstream ss;
17✔
483
                ss << "Nothing to do - the project file does not provide an NTv2 grid file path. " << std::endl << std::endl;
17✔
484
                throw boost::enable_current_exception(std::runtime_error(ss.str()));
51✔
485
        }
17✔
486
}
7✔
487

488
void CDnaProjectFile::InitialiseSegmentSettings()
1✔
489
{
490
        InitialiseGeneralSettings();
1✔
491

492
        std::string firstPart(settings_.g.output_folder + FOLDER_SLASH + settings_.g.network_name + ".");
3✔
493
        settings_.s.bst_file = firstPart + "bst";        // binary stations file
1✔
494
        settings_.s.bms_file = firstPart + "bms";        // binary measurements file
1✔
495
        settings_.s.asl_file = firstPart + "asl";        // associated stations list
1✔
496
        settings_.s.aml_file = firstPart + "aml";        // associated measurements list
1✔
497
        settings_.s.map_file = firstPart + "map";        // station names map
1✔
498
        settings_.s.seg_file = firstPart + "seg";        // segmentation file
1✔
499
        settings_.s.sap_file = firstPart + "sap";        // station appearance file
2✔
500
}
1✔
501

502
void CDnaProjectFile::InitialiseAdjustSettings()
1✔
503
{
504
        InitialiseGeneralSettings();
1✔
505

506
        std::string firstPart(settings_.g.output_folder + FOLDER_SLASH + settings_.g.network_name + ".");
3✔
507
        settings_.a.bst_file = firstPart + "bst";        // binary stations file
1✔
508
        settings_.a.bms_file = firstPart + "bms";        // binary measurements file
1✔
509

510
        if (!boost::filesystem::exists(settings_.a.bst_file) || !boost::filesystem::exists(settings_.a.bms_file))
3✔
511
        {
NEW
512
                std::stringstream ss;
×
513
                ss << "- Nothing to do: ";  
×
514
                        
515
                if (settings_.g.network_name.empty())
×
NEW
516
                        ss << std::endl << "network name has not been specified specified, and " << std::endl << "               ";  
×
NEW
517
                ss << settings_.a.bst_file << " and " << settings_.a.bms_file << " do not exist." << std::endl << std::endl;  
×
NEW
518
                throw boost::enable_current_exception(std::runtime_error(ss.str()));
×
UNCOV
519
        }
×
520
        
521
        // Station appearance file
522
        settings_.a.seg_file = firstPart + "seg";        // segmentation file
1✔
523
        settings_.s.sap_file = firstPart + "sap";        // station appearance file
1✔
524
        settings_.s.asl_file = firstPart + "asl";        // associated stations list
1✔
525
        settings_.s.aml_file = firstPart + "aml";        // associated measurements list
1✔
526
        settings_.a.map_file = firstPart + "map";        // station names map
1✔
527

528
        // Set up file names dependent on adjustment mode
529
        settings_.o._xyz_file = settings_.o._adj_file = 
1✔
530
                formPath<std::string>(settings_.g.output_folder, settings_.g.network_name);
3✔
531

532
        if (settings_.o._positional_uncertainty)
1✔
533
                settings_.o._apu_file = settings_.o._adj_file;
×
534

535
        if (settings_.o._init_stn_corrections)
1✔
536
                settings_.o._cor_file = settings_.o._adj_file;
×
537

538
        switch (settings_.a.adjust_mode)
1✔
539
        {
540
        case Phased_Block_1Mode:
×
541
        case PhasedMode:
×
542

543
                settings_.o._adj_file += ".phased";
×
544
                settings_.o._xyz_file += ".phased";
×
545

546
                if (settings_.o._positional_uncertainty)
×
547
                        settings_.o._apu_file += ".phased";
×
548

549
                if (settings_.o._init_stn_corrections)
×
550
                        settings_.o._cor_file += ".phased";
×
551
                
552
                if (settings_.a.adjust_mode == Phased_Block_1Mode)
×
553
                {
554
                        settings_.o._adj_file += "-block1";
×
555
                        settings_.o._xyz_file += "-block1";
×
556
                        
557
                        if (settings_.o._positional_uncertainty)
×
558
                                settings_.o._apu_file += "-block1";
×
559

560
                        if (settings_.o._init_stn_corrections)
×
561
                                settings_.o._cor_file += "-block1";
×
562

563
                }
564
                else if (settings_.a.stage)
×
565
                {
566
                        settings_.o._adj_file += "-stage";
×
567
                        settings_.o._xyz_file += "-stage";
×
568

569
                        if (settings_.o._positional_uncertainty)
×
570
                                settings_.o._apu_file += "-stage";
×
571

572
                        if (settings_.o._init_stn_corrections)
×
573
                                settings_.o._cor_file += "-stage";
×
574

575
                }
576
#ifdef MULTI_THREAD_ADJUST
577
                else if (settings_.a.multi_thread)
×
578
                {
579
                        settings_.o._adj_file += "-mt";
×
580
                        settings_.o._xyz_file += "-mt";
×
581
                        
582
                        if (settings_.o._positional_uncertainty)
×
583
                                settings_.o._apu_file += "-mt";
×
584

585
                        if (settings_.o._init_stn_corrections)
×
586
                                settings_.o._cor_file += "-mt";
×
587
                }
588
#endif
589
                break;
590
        case SimultaneousMode:
1✔
591
                settings_.o._adj_file += ".simult";
1✔
592
                settings_.o._xyz_file += ".simult";
1✔
593
                
594
                if (settings_.o._positional_uncertainty)
1✔
595
                        settings_.o._apu_file += ".simult";
×
596
                if (settings_.o._init_stn_corrections)
1✔
597
                        settings_.o._cor_file += ".simult";
×
598
                break;
599
        }
600

601
        settings_.o._adj_file += ".adj";
1✔
602
        settings_.o._xyz_file += ".xyz";
1✔
603

604
        if (settings_.o._positional_uncertainty)
1✔
605
                settings_.o._apu_file += ".apu";
×
606

607
        if (settings_.o._init_stn_corrections)
1✔
608
                settings_.o._cor_file += ".cor";
×
609

610
        if (settings_.a.fixed_std_dev < 0.)
1✔
611
                settings_.a.fixed_std_dev = PRECISION_1E6;
×
612
        else if (settings_.a.fixed_std_dev < PRECISION_1E10)
1✔
613
                settings_.a.fixed_std_dev = PRECISION_1E6;
×
614

615
        if (settings_.a.free_std_dev < 0.)
1✔
616
                settings_.a.free_std_dev = 10.0;
×
617
        else if (settings_.a.free_std_dev < PRECISION_1E10)
1✔
618
                settings_.a.free_std_dev = 10.0;
×
619

620
}
1✔
621

622
void CDnaProjectFile::LoadSettingGeneral(const settingMode mSetting, const std::string& var, std::string& val)
4,403✔
623
{
624
        // general settings
625
        if (boost::iequals(var, QUIET))
4,403✔
626
        {
627
                if (val.empty())
629✔
628
                        return;                        
629
                settings_.g.quiet = yesno_uint<UINT16, std::string>(val);
629✔
630
        }
631
        else if (boost::iequals(var, VERBOSE))
3,774✔
632
        {
633
                if (val.empty())
629✔
634
                        return;
635
                settings_.g.verbose = boost::lexical_cast<UINT16, std::string>(val);
629✔
636
        }
637
        else if (boost::iequals(var, PROJECT_FILE))
3,145✔
638
        {
639
                if (val.empty())
629✔
640
                        return;                        
641
                settings_.g.project_file = val;
629✔
642
        }
643
        else if (boost::iequals(var, DYNADJUST_LOG_FILE))
2,516✔
644
        {
645
                if (val.empty())
629✔
646
                        return;                        
647
                settings_.g.log_file = val;
629✔
648
        }
649
        else if (boost::iequals(var, NETWORK_NAME))
1,887✔
650
        {
651
                if (val.empty())
629✔
652
                        return;
×
653
                string_string_pair t;
629✔
654
                switch (mSetting)
629✔
655
                {
656
                case switchSetting:
×
657
                        t.first = var.c_str();
×
658
                        t.second = val.substr(0,4).c_str();
×
659
                        t.second = trimstr(t.second);
×
660
                        if (t.second.substr(0,2) == "${" && t.second.at(3) == '}')
×
661
                        {
662
                                settings_.g.variables.push_back(t);
×
NEW
663
                                std::sort(settings_.g.variables.begin(), settings_.g.variables.end(), PairCompareFirst<std::string, std::string>());
×
664
                        }
665
                        break;
666
                case generalSetting:
629✔
667
                        settings_.g.network_name = val;
629✔
668
                        break;
669
                default:
670
                          break;
671
                }                        
672
        }
629✔
673
        else if (boost::iequals(var, INPUT_FOLDER))
1,258✔
674
        {
675
                if (val.empty())
629✔
676
                        return;                        
677
                settings_.g.input_folder = val;
629✔
678
        }
679
        else if (boost::iequals(var, OUTPUT_FOLDER))
629✔
680
        {
681
                if (val.empty())
629✔
682
                        return;                        
683
                settings_.g.output_folder = val;
629✔
684
        }
685
                
686
}
687
        
688
void CDnaProjectFile::LoadSettingImport(const settingMode mSetting, const std::string& var, std::string& val)
24,567✔
689
{
690
        // Import settings
691
        if (boost::iequals(var, IMPORT_FILE))
24,567✔
692
        {
693
                if (val.empty())
1,296✔
694
                        return;                        
695
                settings_.i.input_files.push_back(formPath<std::string>(settings_.g.input_folder, val));
5,184✔
696
        }
697
        else if (boost::iequals(var, REFERENCE_FRAME))
23,271✔
698
        {
699
                if (val.empty())
629✔
700
                        return;
701
                settings_.i.reference_frame = val;
629✔
702
        }
703
        else if (boost::iequals(var, EPOCH))
22,642✔
704
        {
705
                if (val.empty())
628✔
706
                        return;
707
                settings_.i.epoch = val;
628✔
708
        }
709
        else if (boost::iequals(var, OVERRIDE_INPUT_FRAME))
22,014✔
710
        {
711
                if (val.empty())
629✔
712
                        return;
713
                settings_.i.override_input_rfame = yesno_uint<UINT16, std::string>(val);;
629✔
714
        }
715
        else if (boost::iequals(var, IMPORT_GEO_FILE))
21,385✔
716
        {
717
                if (val.empty())
629✔
718
                        return;
719
                settings_.i.geo_file = formPath<std::string>(settings_.g.input_folder, val);
2✔
720
                settings_.i.import_geo_file = 1;
1✔
721
        }
722
        else if (boost::iequals(var, BIN_STN_FILE))
20,756✔
723
        {
724
                string_string_pair t;
×
725
                switch (mSetting)
×
726
                {
727
                case switchSetting:
×
728
                        if (val.empty())
×
729
                                return;
×
730
                        t.first = var.c_str();
×
731
                        t.second = val.substr(0,4).c_str();
×
732
                        t.second = trimstr(t.second);
×
733
                        if (t.second.substr(0,2) == "${" && t.second.at(3) == '}')
×
734
                        {
735
                                settings_.g.variables.push_back(t);
×
NEW
736
                                std::sort(settings_.g.variables.begin(), settings_.g.variables.end(), PairCompareFirst<std::string, std::string>());
×
737
                        }
738
                        break;
739
                case importSetting:
×
740
                        if (val.empty())
×
741
                                // default export bst file - create in output folder
NEW
742
                                settings_.i.bst_file = formPath<std::string>(settings_.g.output_folder, settings_.g.network_name, "bst");        // binary stations file
×
743
                        else
744
                                // user specified bst file - look in input folder
NEW
745
                                settings_.i.bst_file = formPath<std::string>(settings_.g.input_folder, val);
×
746
                        break;
747
                default:
748
                          break;
749
                }
750
        }
×
751
        else if (boost::iequals(var, BIN_MSR_FILE))
20,756✔
752
        {
753
                string_string_pair t;
×
754
                switch (mSetting)
×
755
                {
756
                case switchSetting:
×
757
                        if (val.empty())
×
758
                                return;
×
759
                        t.first = var.c_str();
×
760
                        t.second = val.substr(0,4).c_str();
×
761
                        t.second = trimstr(t.second);
×
762
                        if (t.second.substr(0,2) == "${" && t.second.at(3) == '}')
×
763
                        {
764
                                settings_.g.variables.push_back(t);
×
NEW
765
                                std::sort(settings_.g.variables.begin(), settings_.g.variables.end(), PairCompareFirst<std::string, std::string>());
×
766
                        }
767
                        break;
768
                case importSetting:
×
769
                        if (val.empty())
×
NEW
770
                                settings_.i.bms_file = formPath<std::string>(settings_.g.output_folder, settings_.g.network_name, "bms");        // binary stations file
×
771
                        else
NEW
772
                                settings_.i.bms_file = formPath<std::string>(settings_.g.input_folder, val);
×
773
                        break;
774
                default:
775
                          break;
776
                }
777
        }
×
778
        else if (boost::iequals(var, MAP_FILE))
20,756✔
779
        {
780
                if (val.empty())
×
781
                        return;
×
782
                string_string_pair t;
×
783
                switch (mSetting)
×
784
                {
785
                case switchSetting:
×
786
                        t.first = var.c_str();
×
787
                        t.second = val.substr(0,4).c_str();
×
788
                        t.second = trimstr(t.second);
×
789
                        if (t.second.substr(0,2) == "${" && t.second.at(3) == '}')
×
790
                        {
791
                                settings_.g.variables.push_back(t);
×
NEW
792
                                std::sort(settings_.g.variables.begin(), settings_.g.variables.end(), PairCompareFirst<std::string, std::string>());
×
793
                        }
794
                        break;
795
                case importSetting:
×
NEW
796
                        settings_.i.map_file = formPath<std::string>(settings_.g.output_folder, val);
×
797
                        break;
×
798
                default:
799
                          break;
800
                }                        
801
        }
×
802
        else if (boost::iequals(var, ASL_FILE))
20,756✔
803
        {
804
                if (val.empty())
×
805
                        return;
×
806
                string_string_pair t;
×
807
                switch (mSetting)
×
808
                {
809
                case switchSetting:
×
810
                        t.first = var.c_str();
×
811
                        t.second = val.substr(0,4).c_str();
×
812
                        t.second = trimstr(t.second);
×
813
                        if (t.second.substr(0,2) == "${" && t.second.at(3) == '}')
×
814
                        {
815
                                settings_.g.variables.push_back(t);
×
NEW
816
                                std::sort(settings_.g.variables.begin(), settings_.g.variables.end(), PairCompareFirst<std::string, std::string>());
×
817
                        }
818
                        break;
819
                case importSetting:
×
NEW
820
                        settings_.i.asl_file = formPath<std::string>(settings_.g.output_folder, val);
×
821
                        break;
×
822
                default:
823
                          break;
824
                }
825
        }
×
826
        else if (boost::iequals(var, AML_FILE))
20,756✔
827
        {
828
                if (val.empty())
×
829
                        return;
×
830
                string_string_pair t;
×
831
                switch (mSetting)
×
832
                {
833
                case switchSetting:
×
834
                        t.first = var.c_str();
×
835
                        t.second = val.substr(0,4).c_str();
×
836
                        t.second = trimstr(t.second);
×
837
                        if (t.second.substr(0,2) == "${" && t.second.at(3) == '}')
×
838
                        {
839
                                settings_.g.variables.push_back(t);
×
NEW
840
                                std::sort(settings_.g.variables.begin(), settings_.g.variables.end(), PairCompareFirst<std::string, std::string>());
×
841
                        }
842
                        break;
843
                case importSetting:
×
NEW
844
                        settings_.i.aml_file = formPath<std::string>(settings_.g.output_folder, val);
×
845
                        break;
×
846
                default:
847
                          break;
848
                }
849
        }
×
850
        else if (boost::iequals(var, DST_FILE))
20,756✔
851
        {
852
                if (val.empty())
×
853
                        return;
NEW
854
                settings_.i.dst_file = formPath<std::string>(settings_.g.output_folder, val);
×
855
        }
856
        else if (boost::iequals(var, DMS_FILE))
20,756✔
857
        {
858
                if (val.empty())
×
859
                        return;
NEW
860
                settings_.i.dms_file = formPath<std::string>(settings_.g.output_folder, val);
×
861
        }
862
        else if (boost::iequals(var, BOUNDING_BOX))
20,756✔
863
        {
864
                if (val.empty())
629✔
865
                        return;
866
                settings_.i.bounding_box = val;
1✔
867
        }
868
        else if (boost::iequals(var, GET_MSRS_TRANSCENDING_BOX))
20,127✔
869
        {
870
                if (val.empty())
629✔
871
                        return;
872
                settings_.i.include_transcending_msrs = yesno_uint<UINT16, std::string>(val);
629✔
873
        }
874
        else if (boost::iequals(var, INCLUDE_STN_ASSOC_MSRS))
19,498✔
875
        {
876
                if (val.empty())
629✔
877
                        return;
878
                settings_.i.stn_associated_msr_include = valorno_string<std::string>(val);
1,258✔
879
        }
880
        else if (boost::iequals(var, EXCLUDE_STN_ASSOC_MSRS))
18,869✔
881
        {
882
                if (val.empty())
629✔
883
                        return;
884
                settings_.i.stn_associated_msr_exclude = valorno_string<std::string>(val);
1,258✔
885
        }
886
        else if (boost::iequals(var, SPLIT_CLUSTERS))
18,240✔
887
        {
888
                if (val.empty())
629✔
889
                        return;
890
                settings_.i.split_clusters = yesno_uint<UINT16, std::string>(val);
629✔
891
        }
892
        else if (boost::iequals(var, IMPORT_SEG_BLOCK))
17,611✔
893
        {
894
                if (val.empty())
629✔
895
                        return;
896
                settings_.i.import_block_number = valorno_uint<UINT16, std::string>(val, settings_.i.import_block);
629✔
897
        }
898
        else if (boost::iequals(var, SEG_FILE))
16,982✔
899
        {
900
                if (val.empty())
629✔
901
                        return;
902
                settings_.i.seg_file = formPath<std::string>(settings_.g.input_folder, val);
3✔
903
        }
904
        else if (boost::iequals(var, PREFER_X_MSR_AS_G))
16,353✔
905
        {
906
                if (val.empty())
629✔
907
                        return;
908
                settings_.i.prefer_single_x_as_g = yesno_uint<UINT16, std::string>(val);
629✔
909
        }
910
        else if (boost::iequals(var, INCLUDE_MSRS))
15,724✔
911
        {
912
                if (val.empty())
629✔
913
                        return;
914
                settings_.i.include_msrs = val;
1✔
915
        }
916
        else if (boost::iequals(var, EXCLUDE_MSRS))
15,095✔
917
        {
918
                if (val.empty())
629✔
919
                        return;
920
                settings_.i.exclude_msrs = val;
1✔
921
        }
922
        else if (boost::iequals(var, STATION_RENAMING_FILE))
14,466✔
923
        {
924
                if (val.empty())
629✔
925
                        return;
926
                settings_.i.stn_renamingfile = formPath<std::string>(settings_.g.input_folder, val);
3✔
927
        }
928
        else if (boost::iequals(var, STATION_DISCONTINUITY_FILE))
13,837✔
929
        {
930
                if (val.empty())
629✔
931
                        return;
932
                settings_.i.stn_discontinuityfile = formPath<std::string>(settings_.g.input_folder, val);
12✔
933
                settings_.i.apply_discontinuities = true;
6✔
934
        }
935
        else if (boost::iequals(var, TEST_NEARBY_STNS))
13,208✔
936
        {
937
                if (val.empty())
629✔
938
                        return;
939
                settings_.i.search_nearby_stn = yesno_uint<UINT16, std::string>(val);
629✔
940
        }
941
        else if (boost::iequals(var, TEST_NEARBY_STN_DIST))
12,579✔
942
        {
943
                if (val.empty())
629✔
944
                        return;
945
                settings_.i.search_stn_radius = DoubleFromString<double>(val);
629✔
946
        }
947
        else if (boost::iequals(var, TEST_SIMILAR_MSRS))
11,950✔
948
        {
949
                if (val.empty())
629✔
950
                        return;
951
                settings_.i.search_similar_msr = yesno_uint<UINT16, std::string>(val);
629✔
952
        }
953
        else if (boost::iequals(var, TEST_SIMILAR_GNSS_MSRS))
11,321✔
954
        {
955
                if (val.empty())
629✔
956
                        return;
957
                settings_.i.search_similar_msr_gx = yesno_uint<UINT16, std::string>(val);
629✔
958
        }
959
        else if (boost::iequals(var, IGNORE_INSUFFICIENT_MSRS))
10,692✔
960
        {
961
                if (val.empty())
628✔
962
                        return;
963
                settings_.i.ignore_insufficient_msrs = yesno_uint<UINT16, std::string>(val);
628✔
964
                }
965
        else if (boost::iequals(var, IGNORE_SIMILAR_MSRS))
10,064✔
966
        {
967
                if (val.empty())
629✔
968
                        return;
969
                settings_.i.ignore_similar_msr = yesno_uint<UINT16, std::string>(val);
629✔
970
        }
971
        else if (boost::iequals(var, REMOVE_IGNORED_MSRS))
9,435✔
972
        {
973
                if (val.empty())
629✔
974
                        return;
975
                settings_.i.remove_ignored_msr = yesno_uint<UINT16, std::string>(val);
629✔
976
        }
977
        else if (boost::iequals(var, FLAG_UNUSED_STNS))
8,806✔
978
        {
979
                if (val.empty())
629✔
980
                        return;
981
                settings_.i.flag_unused_stn = yesno_uint<UINT16, std::string>(val);
629✔
982
        }
983
        else if (boost::iequals(var, TEST_INTEGRITY))
8,177✔
984
        {
985
                if (val.empty())
629✔
986
                        return;                        
987
                settings_.i.test_integrity = yesno_uint<UINT16, std::string>(val);
629✔
988
        }
989
        else if (boost::iequals(var, VSCALE))
7,548✔
990
        {
991
                if (val.empty())
629✔
992
                        return;
993
                settings_.i.vscale = DoubleFromString<double>(val);
629✔
994
        }
995
        else if (boost::iequals(var, PSCALE))
6,919✔
996
        {
997
                if (val.empty())
629✔
998
                        return;
999
                settings_.i.pscale = DoubleFromString<double>(val);
629✔
1000
        }
1001
        else if (boost::iequals(var, LSCALE))
6,290✔
1002
        {
1003
                if (val.empty())
629✔
1004
                        return;
1005
                settings_.i.lscale = DoubleFromString<double>(val);
629✔
1006
        }
1007
        else if (boost::iequals(var, HSCALE))
5,661✔
1008
        {
1009
                if (val.empty())
629✔
1010
                        return;
1011
                settings_.i.hscale = DoubleFromString<double>(val);
629✔
1012
        }
1013
        else if (boost::iequals(var, SCALAR_FILE))
5,032✔
1014
        {
1015
                if (val.empty())
629✔
1016
                        return;
NEW
1017
                settings_.i.scalar_file = formPath<std::string>(settings_.g.input_folder, val);
×
1018
        }
1019
        else if (boost::iequals(var, EXPORT_XML_FILES))
4,403✔
1020
        {
1021
                if (val.empty())
629✔
1022
                        return;                        
1023
                settings_.i.export_dynaml = yesno_uint<UINT16, std::string>(val);
629✔
1024
        }
1025
        else if (boost::iequals(var, EXPORT_SINGLE_XML_FILE))
3,774✔
1026
        {
1027
                if (val.empty())
629✔
1028
                        return;                        
1029
                settings_.i.export_single_xml_file = yesno_uint<UINT16, std::string>(val);
629✔
1030
        }
1031
        else if (boost::iequals(var, EXPORT_FROM_BINARY))
3,145✔
1032
        {
1033
                if (val.empty())
×
1034
                        return;                        
NEW
1035
                settings_.i.export_from_bfiles = yesno_uint<UINT16, std::string>(val);
×
1036
        }
1037
        else if (boost::iequals(var, EXPORT_DNA_FILES))
3,145✔
1038
        {
1039
                if (val.empty())
629✔
1040
                        return;                        
1041
                settings_.i.export_dna_files = yesno_uint<UINT16, std::string>(val);
629✔
1042
        }
1043
        else if (boost::iequals(var, EXPORT_ASL_FILE))
2,516✔
1044
        {
1045
                if (val.empty())
629✔
1046
                        return;                        
1047
                settings_.i.export_asl_file = yesno_uint<UINT16, std::string>(val);
629✔
1048
        }
1049
        else if (boost::iequals(var, EXPORT_AML_FILE))
1,887✔
1050
        {
1051
                if (val.empty())
629✔
1052
                        return;                        
1053
                settings_.i.export_aml_file = yesno_uint<UINT16, std::string>(val);
629✔
1054
        }
1055
        else if (boost::iequals(var, EXPORT_MAP_FILE))
1,258✔
1056
        {
1057
                if (val.empty())
629✔
1058
                        return;                        
1059
                settings_.i.export_map_file = yesno_uint<UINT16, std::string>(val);
629✔
1060
        }
1061
        else if (boost::iequals(var, SIMULATE_MSR_FILE))
629✔
1062
        {
1063
                if (val.empty())
629✔
1064
                        return;                        
1065
                settings_.i.simulate_measurements = yesno_uint<UINT16, std::string>(val);
629✔
1066
        }
1067
        //else if (boost::iequals(var, VERIFY_COORDS))
1068
        //{
1069
        //        if (val.empty())
1070
        //                return;                        
1071
        //        settings_.i.verify_coordinates = boost::lexical_cast<UINT16, std::string>(val);
1072
        //}
1073
        
1074
}
1075
        
1076
void CDnaProjectFile::LoadSettingReftran(const std::string& var, std::string& val)
3,142✔
1077
{
1078
        if (boost::iequals(var, REFERENCE_FRAME))
3,142✔
1079
        {
1080
                if (val.empty())
629✔
1081
                        return;
1082
                settings_.r.reference_frame = val;
629✔
1083
        }
1084
        else if (boost::iequals(var, EPOCH))
2,513✔
1085
        {
1086
                if (val.empty())
629✔
1087
                        return;
1088
                settings_.r.epoch = val;
628✔
1089
        }
1090
        else if (boost::iequals(var, TECTONIC_PLATE_MODEL_OPTION))
1,884✔
1091
        {
1092
                if (val.empty())
628✔
1093
                        return;
1094
                settings_.r.plate_model_option = boost::lexical_cast<UINT16, std::string>(val);
628✔
1095
        }
1096
        else if (boost::iequals(var, TECTONIC_PLATE_BDY_FILE))
1,256✔
1097
        {
1098
                if (val.empty())
628✔
1099
                        return;
1100
                settings_.r.tpb_file = val;
×
1101

NEW
1102
                if (!boost::filesystem::exists(val))
×
NEW
1103
                        if (boost::filesystem::exists(formPath<std::string>(settings_.g.input_folder, val)))
×
NEW
1104
                                settings_.r.tpb_file = formPath<std::string>(settings_.g.input_folder, val);
×
1105
        }
1106
        else if (boost::iequals(var, TECTONIC_PLATE_POLE_FILE))
628✔
1107
        {
1108
                if (val.empty())
628✔
1109
                        return;
1110
                settings_.r.tpp_file = val;
×
1111

NEW
1112
                if (!boost::filesystem::exists(val))
×
NEW
1113
                        if (boost::filesystem::exists(formPath<std::string>(settings_.g.input_folder, val)))
×
NEW
1114
                                settings_.r.tpp_file = formPath<std::string>(settings_.g.input_folder, val);
×
1115
        }
1116
}
1117
        
1118
void CDnaProjectFile::LoadSettingGeoid(const std::string& var, std::string& val)
3,146✔
1119
{
1120
        if (boost::iequals(var, DAT_FILEPATH))
3,146✔
1121
        {
1122
                if (val.empty())
×
1123
                        return;
NEW
1124
                settings_.n.rdat_geoid_file = formPath<std::string>(settings_.g.input_folder, val);
×
1125
        }
1126
        else if (boost::iequals(var, NTV2_FILEPATH))
3,146✔
1127
        {
1128
                if (val.empty())
629✔
1129
                        return;
1130
                settings_.n.ntv2_geoid_file = val;
472✔
1131

1132
                if (!boost::filesystem::exists(val))
944✔
NEW
1133
                        if (boost::filesystem::exists(formPath<std::string>(settings_.g.input_folder, val)))
×
NEW
1134
                                settings_.n.ntv2_geoid_file = formPath<std::string>(settings_.g.input_folder, val);
×
1135
        }
1136
        else if (boost::iequals(var, INPUT_FILE))
2,517✔
1137
        {
1138
                if (val.empty())
×
1139
                        return;
NEW
1140
                settings_.n.input_file = formPath<std::string>(settings_.g.input_folder, val);
×
1141
        }
1142
        //else if (boost::iequals(var, BIN_STN_FILE))
1143
        //{
1144
        //        if (val.empty())
1145
        //                return;
1146
        //        settings_.n.bst_file = formPath<std::string>(settings_.g.input_folder, val);
1147
        //}
1148
        else if (boost::iequals(var, METHOD))
2,517✔
1149
        {
1150
                if (val.empty())
629✔
1151
                        return;
1152
                settings_.n.interpolation_method = boost::lexical_cast<UINT16, std::string>(val);
629✔
1153
        }
1154
        else if (boost::iequals(var, DDEG_FORMAT))
1,888✔
1155
        {
1156
                if (val.empty())
629✔
1157
                        return;
1158
                settings_.n.coordinate_format = boost::lexical_cast<UINT16, std::string>(val);
629✔
1159
        }
1160
        else if (boost::iequals(var, DIRECTION))
1,259✔
1161
        {
1162
                if (val.empty())
629✔
1163
                        return;
1164
                settings_.n.ellipsoid_to_ortho = boost::lexical_cast<UINT16, std::string>(val);
629✔
1165
        }
1166
        else if (boost::iequals(var, CONVERT_BST_HT))
630✔
1167
        {
1168
                if (val.empty())
1✔
1169
                        return;
1170
                settings_.n.convert_heights = yesno_uint<UINT16, std::string>(val);
1✔
1171
        }
1172
        else if (boost::iequals(var, EXPORT_GEO_FILE))
629✔
1173
        {
1174
                if (val.empty())
629✔
1175
                        return;
1176
                settings_.n.export_dna_geo_file = yesno_uint<UINT16, std::string>(val);
629✔
1177
        }
1178
}
1179
        
1180
void CDnaProjectFile::LoadSettingSegment(const std::string& var, std::string& val)
3,774✔
1181
{
1182
        if (boost::iequals(var, NET_FILE))
3,774✔
1183
        {
1184
                if (val.empty())
629✔
1185
                        return;
1186
                settings_.s.net_file = formPath<std::string>(settings_.g.input_folder, val);
63✔
1187
        }
1188
        else if (boost::iequals(var, SEG_FILE))
3,145✔
1189
        {
1190
                if (val.empty())
629✔
1191
                        return;
1192
                settings_.s.seg_file = val;
4✔
1193

1194
                if (!boost::filesystem::exists(val))
8✔
NEW
1195
                        if (boost::filesystem::exists(formPath<std::string>(settings_.g.input_folder, val)))
×
NEW
1196
                                settings_.s.seg_file = formPath<std::string>(settings_.g.input_folder, val);
×
1197
        }
1198
        else if (boost::iequals(var, BIN_STN_FILE))
2,516✔
1199
        {
1200
                if (val.empty())
×
1201
                        return;
1202
                settings_.s.bst_file = val;
×
1203

NEW
1204
                if (!boost::filesystem::exists(val))
×
NEW
1205
                        if (boost::filesystem::exists(formPath<std::string>(settings_.g.input_folder, val)))
×
NEW
1206
                                settings_.s.bst_file = formPath<std::string>(settings_.g.input_folder, val);
×
1207
        }
1208
        else if (boost::iequals(var, BIN_MSR_FILE))
2,516✔
1209
        {
1210
                if (val.empty())
×
1211
                        return;
1212
                settings_.s.bms_file = val;
×
1213

NEW
1214
                if (!boost::filesystem::exists(val))
×
NEW
1215
                        if (boost::filesystem::exists(formPath<std::string>(settings_.g.input_folder, val)))
×
NEW
1216
                                settings_.s.bms_file = formPath<std::string>(settings_.g.input_folder, val);
×
1217
        }
1218
        else if (boost::iequals(var, SEG_MIN_INNER_STNS))
2,516✔
1219
        {
1220
                if (val.empty())
629✔
1221
                        return;
1222
                settings_.s.min_inner_stations = boost::lexical_cast<UINT32, std::string>(val);
629✔
1223
        }
1224
        else if (boost::iequals(var, SEG_THRESHOLD_STNS))
1,887✔
1225
        {
1226
                if (val.empty())
629✔
1227
                        return;
1228
                settings_.s.max_total_stations = boost::lexical_cast<UINT32, std::string>(val);
629✔
1229
        }
1230
        else if (boost::iequals(var, SEG_FORCE_CONTIGUOUS))
1,258✔
1231
        {
1232
                if (val.empty())
629✔
1233
                        return;
1234
                settings_.s.force_contiguous_blocks = yesno_uint<UINT16, std::string>(val);
629✔
1235
        }
1236
        else if (boost::iequals(var, SEG_STARTING_STN))
629✔
1237
        {
1238
                if (val.empty())
629✔
1239
                        return;
1240
                settings_.s.seg_starting_stns = val;
26✔
1241
        }
NEW
1242
        else if (boost::iequals(var, SEG_SEARCH_LEVEL))
×
1243
        {
1244
                if (val.empty())
×
1245
                        return;
NEW
1246
                settings_.s.seg_search_level = boost::lexical_cast<UINT16, std::string>(val);
×
1247
        }
1248
}
1249
        
1250
void CDnaProjectFile::LoadSettingAdjust(const std::string& var, std::string& val)
10,062✔
1251
{
1252
        if (boost::iequals(var, BIN_STN_FILE))
10,062✔
1253
        {
1254
                if (val.empty())
×
1255
                        return;
1256
                settings_.a.bst_file = val;
×
1257

NEW
1258
                if (!boost::filesystem::exists(val))
×
NEW
1259
                        if (boost::filesystem::exists(formPath<std::string>(settings_.g.input_folder, val)))
×
NEW
1260
                                settings_.a.bst_file = formPath<std::string>(settings_.g.input_folder, val);
×
1261
        }
1262
        else if (boost::iequals(var, BIN_MSR_FILE))
10,062✔
1263
        {
1264
                if (val.empty())
×
1265
                        return;
1266
                settings_.a.bms_file = val;
×
1267

NEW
1268
                if (!boost::filesystem::exists(val))
×
NEW
1269
                        if (boost::filesystem::exists(formPath<std::string>(settings_.g.input_folder, val)))
×
NEW
1270
                                settings_.a.bms_file = formPath<std::string>(settings_.g.input_folder, val);
×
1271
        }
1272
        else if (boost::iequals(var, SEG_FILE))
10,062✔
1273
        {
1274
                if (val.empty())
629✔
1275
                        return;
1276
                settings_.a.seg_file = val;
×
1277

NEW
1278
                if (!boost::filesystem::exists(val))
×
NEW
1279
                        if (boost::filesystem::exists(formPath<std::string>(settings_.g.input_folder, val)))
×
NEW
1280
                                settings_.a.seg_file = formPath<std::string>(settings_.g.input_folder, val);
×
1281
        }
1282
        else if (boost::iequals(var, COMMENTS))
9,433✔
1283
        {
1284
                if (val.empty())
629✔
1285
                        return;
1286
                settings_.a.comments = val;                
6✔
1287
        }
1288
        if (boost::iequals(var, ADJUSTMENT_MODE))
8,810✔
1289
        {
1290
                if (val.empty())
629✔
1291
                        return;
1292
                if (boost::iequals(val, MODE_SIMULTANEOUS))
629✔
1293
                {
1294
                        settings_.a.adjust_mode = SimultaneousMode;
603✔
1295
                        settings_.a.multi_thread = false;
603✔
1296
                        settings_.a.stage = false;
603✔
1297
                }
1298
                else if (boost::iequals(val, MODE_PHASED))
26✔
1299
                {
1300
                        settings_.a.adjust_mode = PhasedMode;
22✔
1301
                }
1302
                else if (boost::iequals(val, MODE_PHASED_BLOCK1))
4✔
1303
                {
1304
                        settings_.a.adjust_mode = Phased_Block_1Mode;
4✔
1305
                        settings_.a.multi_thread = false;
4✔
1306
                }
NEW
1307
                else if (boost::iequals(val, MODE_SIMULATION))
×
1308
                {
1309
                        settings_.a.adjust_mode = SimulationMode;
×
1310
                        settings_.a.multi_thread = false;
×
1311
                        settings_.a.stage = false;
×
1312
                }
1313
        }
1314

1315
        else if (boost::iequals(var, MODE_PHASED_MT))
8,181✔
1316
        {
1317
                if (val.empty())
629✔
1318
                        return;
1319
                settings_.a.multi_thread = yesno_uint<UINT16, std::string>(val);
629✔
1320
        }
1321
        else if (boost::iequals(var, STAGED_ADJUSTMENT))
7,552✔
1322
        {
1323
                if (val.empty())
629✔
1324
                        return;
1325
                settings_.a.stage = yesno_uint<UINT16, std::string>(val);
629✔
1326
        }
1327
        
1328
        else if (boost::iequals(var, CONF_INTERVAL))
6,923✔
1329
        {
1330
                if (val.empty())
629✔
1331
                        return;
1332
                settings_.a.confidence_interval = FloatFromString<float>(val);
629✔
1333
        }
1334
        else if (boost::iequals(var, ITERATION_THRESHOLD))
6,294✔
1335
        {
1336
                if (val.empty())
629✔
1337
                        return;
1338
                settings_.a.iteration_threshold = FloatFromString<float>(val);
629✔
1339
        }
1340
        else if (boost::iequals(var, MAX_ITERATIONS))
5,665✔
1341
        {
1342
                if (val.empty())
629✔
1343
                        return;
1344
                settings_.a.max_iterations = boost::lexical_cast<UINT16, std::string>(val);
629✔
1345
        }
1346
        else if (boost::iequals(var, STN_CONSTRAINTS))
5,036✔
1347
        {
1348
                if (val.empty())
629✔
1349
                        return;
1350
                settings_.a.station_constraints = val;
6✔
1351
        }
1352
        else if (boost::iequals(var, FREE_STN_SD))
4,407✔
1353
        {
1354
                if (val.empty())
629✔
1355
                        return;
1356
                settings_.a.free_std_dev = DoubleFromString<double>(val);
629✔
1357
        }
1358
        else if (boost::iequals(var, FIXED_STN_SD))
3,778✔
1359
        {
1360
                if (val.empty())
629✔
1361
                        return;
1362
                settings_.a.fixed_std_dev = DoubleFromString<double>(val);
629✔
1363
        }
1364
        //else if (boost::iequals(var, LSQ_INVERSE_METHOD))
1365
        //{
1366
        //        if (val.empty())
1367
        //                return;
1368
        //        settings_.a.inverse_method_lsq = boost::lexical_cast<UINT16, std::string>(val);
1369
        //}
1370
        else if (boost::iequals(var, SCALE_NORMAL_UNITY))
3,149✔
1371
        {
1372
                if (val.empty())
629✔
1373
                        return;
1374
                settings_.a.scale_normals_to_unity = yesno_uint<UINT16, std::string>(val);
629✔
1375
        }
1376
        else if (boost::iequals(var, RECREATE_STAGE_FILES))
2,520✔
1377
        {
1378
                if (val.empty())
629✔
1379
                        return;
1380
                settings_.a.recreate_stage_files = yesno_uint<UINT16, std::string>(val);
629✔
1381
        }
1382
        else if (boost::iequals(var, PURGE_STAGE_FILES))
1,891✔
1383
        {
1384
                if (val.empty())
629✔
1385
                        return;
1386
                settings_.a.purge_stage_files = yesno_uint<UINT16, std::string>(val) == 1;
629✔
1387
        }
1388
        else if (boost::iequals(var, TYPE_B_GLOBAL))
1,262✔
1389
        {
1390
                if (val.empty())
628✔
1391
                        return;
UNCOV
1392
                settings_.a.type_b_global = val;
×
1393
        }
1394
        else if (boost::iequals(var, TYPE_B_FILE))
634✔
1395
        {
1396
                if (val.empty())
628✔
1397
                        return;
1398
                settings_.a.type_b_file = val;
×
1399

NEW
1400
                if (!boost::filesystem::exists(val))
×
NEW
1401
                        if (boost::filesystem::exists(formPath<std::string>(settings_.g.input_folder, val)))
×
NEW
1402
                                settings_.a.type_b_file = formPath<std::string>(settings_.g.input_folder, val);
×
1403
        }
1404
}
1405
        
1406
void CDnaProjectFile::LoadSettingOutput(const std::string& var, std::string& val)
29,561✔
1407
{
1408
        if (boost::iequals(var, OUTPUT_MSR_TO_STN))
29,561✔
1409
        {
1410
                if (val.empty())
629✔
1411
                        return;
1412
                settings_.o._msr_to_stn = yesno_uint<UINT16, std::string>(val);
629✔
1413
        }
1414
        else if (boost::iequals(var, OUTPUT_MSR_TO_STN_SORTBY))
28,932✔
1415
        {
1416
                if (val.empty())
629✔
1417
                        return;
1418
                settings_.o._sort_msr_to_stn = boost::lexical_cast<UINT16, std::string>(val);
629✔
1419
        }
1420
        else if (boost::iequals(var, OUTPUT_ADJ_STN_ITER))
28,303✔
1421
        {
1422
                if (val.empty())
629✔
1423
                        return;
1424
                settings_.o._adj_stn_iteration = yesno_uint<UINT16, std::string>(val);
629✔
1425
        }
1426
        else if (boost::iequals(var, OUTPUT_ADJ_STAT_ITER))
27,674✔
1427
        {
1428
                if (val.empty())
629✔
1429
                        return;
1430
                settings_.o._adj_stat_iteration = yesno_uint<UINT16, std::string>(val);
629✔
1431
        }
1432
        else if (boost::iequals(var, OUTPUT_ADJ_MSR_ITER))
27,045✔
1433
        {
1434
                if (val.empty())
629✔
1435
                        return;
1436
                settings_.o._adj_msr_iteration = yesno_uint<UINT16, std::string>(val);
629✔
1437
        }
1438
        else if (boost::iequals(var, OUTPUT_CMP_MSR_ITER))
26,416✔
1439
        {
1440
                if (val.empty())
629✔
1441
                        return;
1442
                settings_.o._cmp_msr_iteration = yesno_uint<UINT16, std::string>(val);
629✔
1443
        }
1444
        else if (boost::iequals(var, OUTPUT_ADJ_MSR))
25,787✔
1445
        {
1446
                if (val.empty())
629✔
1447
                        return;
1448
                settings_.o._adj_msr_final = yesno_uint<UINT16, std::string>(val);
629✔
1449
        }
1450
        else if (boost::iequals(var, OUTPUT_ADJ_GNSS_UNITS))
25,158✔
1451
        {
1452
                if (val.empty())
629✔
1453
                        return;
1454
                settings_.o._adj_gnss_units = boost::lexical_cast<UINT16, std::string>(val);
629✔
1455
        }
1456
        else if (boost::iequals(var, OUTPUT_ADJ_MSR_TSTAT))
24,529✔
1457
        {
1458
                if (val.empty())
629✔
1459
                        return;
1460
                settings_.o._adj_msr_tstat = yesno_uint<UINT16, std::string>(val);
629✔
1461
        }
1462
        else if (boost::iequals(var, OUTPUT_ADJ_MSR_SORTBY))
23,900✔
1463
        {
1464
                if (val.empty())
629✔
1465
                        return;
1466
                settings_.o._sort_adj_msr = boost::lexical_cast<UINT16, std::string>(val);
629✔
1467
        }
1468
        else if (boost::iequals(var, OUTPUT_ADJ_MSR_DBID))
23,271✔
1469
        {
1470
                if (val.empty())
629✔
1471
                        return;
1472
                settings_.o._database_ids = yesno_uint<UINT16, std::string>(val);
629✔
1473
        }
1474
        else if (boost::iequals(var, OUTPUT_ADJ_STN_BLOCKS))
22,642✔
1475
        {
1476
                if (val.empty())
×
1477
                        return;
NEW
1478
                settings_.o._output_stn_blocks = yesno_uint<UINT16, std::string>(val);
×
1479
        }
1480
        else if (boost::iequals(var, OUTPUT_ADJ_MSR_BLOCKS))
22,642✔
1481
        {
1482
                if (val.empty())
629✔
1483
                        return;
1484
                settings_.o._output_msr_blocks = yesno_uint<UINT16, std::string>(val);
629✔
1485
        }
1486
        else if (boost::iequals(var, OUTPUT_ADJ_STN_SORT_ORDER))
22,013✔
1487
        {
1488
                if (val.empty())
629✔
1489
                        return;
1490
                settings_.o._sort_stn_file_order = yesno_uint<UINT16, std::string>(val);
629✔
1491
        }
1492
        else if (boost::iequals(var, OUTPUT_STN_COORD_TYPES))
21,384✔
1493
        {
1494
                if (val.empty())
629✔
1495
                        return;
1496
                settings_.o._stn_coord_types = val;
629✔
1497
        }
1498
        else if (boost::iequals(var, OUTPUT_ANGULAR_TYPE_STN))
20,755✔
1499
        {
1500
                if (val.empty())
629✔
1501
                        return;
1502
                settings_.o._angular_type_stn = boost::lexical_cast<UINT16, std::string>(val);
629✔
1503
        }
1504
        else if (boost::iequals(var, OUTPUT_STN_CORR))
20,126✔
1505
        {
1506
                if (val.empty())
629✔
1507
                        return;
1508
                settings_.o._stn_corr = yesno_uint<UINT16, std::string>(val);
629✔
1509
        }
1510
        else if (boost::iequals(var, OUTPUT_PRECISION_METRES_STN))
19,497✔
1511
        {
1512
                if (val.empty())
629✔
1513
                        return;
1514
                settings_.o._precision_metres_stn = boost::lexical_cast<UINT16, std::string>(val);
629✔
1515
        }
1516
        else if (boost::iequals(var, OUTPUT_PRECISION_SECONDS_STN))
18,868✔
1517
        {
1518
                if (val.empty())
629✔
1519
                        return;
1520
                settings_.o._precision_seconds_stn = boost::lexical_cast<UINT16, std::string>(val);
629✔
1521
        }
1522
        else if (boost::iequals(var, OUTPUT_PRECISION_METRES_MSR))
18,239✔
1523
        {
1524
                if (val.empty())
629✔
1525
                        return;
1526
                settings_.o._precision_metres_msr = boost::lexical_cast<UINT16, std::string>(val);
629✔
1527
        }
1528
        else if (boost::iequals(var, OUTPUT_PRECISION_SECONDS_MSR))
17,610✔
1529
        {
1530
                if (val.empty())
629✔
1531
                        return;
1532
                settings_.o._precision_seconds_msr = boost::lexical_cast<UINT16, std::string>(val);
629✔
1533
        }
1534
        else if (boost::iequals(var, OUTPUT_ANGULAR_TYPE_MSR))
16,981✔
1535
        {
1536
                if (val.empty())
629✔
1537
                        return;
1538
                settings_.o._angular_type_msr = boost::lexical_cast<UINT16, std::string>(val);
629✔
1539
        }
1540
        else if (boost::iequals(var, OUTPUT_DMS_FORMAT_MSR))
16,352✔
1541
        {
1542
                if (val.empty())
629✔
1543
                        return;
1544
                settings_.o._dms_format_msr = boost::lexical_cast<UINT16, std::string>(val);
629✔
1545
        }
1546
        else if (boost::iequals(var, OUTPUT_POS_UNCERTAINTY))
15,723✔
1547
        {
1548
                if (val.empty())
629✔
1549
                        return;
1550
                settings_.o._positional_uncertainty = yesno_uint<UINT16, std::string>(val);
629✔
1551
        }
1552
        else if (boost::iequals(var, OUTPUT_APU_CORRELATIONS))
15,094✔
1553
        {
1554
                if (val.empty())
629✔
1555
                        return;
1556
                settings_.o._output_pu_covariances = yesno_uint<UINT16, std::string>(val);
629✔
1557
        }
1558
        else if (boost::iequals(var, OUTPUT_APU_UNITS))
14,465✔
1559
        {
1560
                if (val.empty())
629✔
1561
                        return;
1562
                settings_.o._apu_vcv_units = boost::lexical_cast<UINT16, std::string>(val);
629✔
1563
        }
1564
        else if (boost::iequals(var, OUTPUT_STN_COR_FILE))
13,836✔
1565
        {
1566
                if (val.empty())
629✔
1567
                        return;
1568
                settings_.o._init_stn_corrections = yesno_uint<UINT16, std::string>(val);
629✔
1569
        }
1570
        else if (boost::iequals(var, HZ_CORR_THRESHOLD))
13,207✔
1571
        {
1572
                if (val.empty())
629✔
1573
                        return;
1574
                settings_.o._hz_corr_threshold = DoubleFromString<double>(val);
629✔
1575
        }
1576
        else if (boost::iequals(var, VT_CORR_THRESHOLD))
12,578✔
1577
        {
1578
                if (val.empty())
629✔
1579
                        return;
1580
                settings_.o._vt_corr_threshold = DoubleFromString<double>(val);
629✔
1581
        }
1582
        //else if (boost::iequals(var, UPDATE_ORIGINAL_STN_FILE))
1583
        //{
1584
        //        if (val.empty())
1585
        //                return;
1586
        //        settings_.o. = yesno_uint<UINT16, std::string>(val);
1587
        //}
1588
        else if (boost::iequals(var, EXPORT_XML_STN_FILE))
11,949✔
1589
        {
1590
                if (val.empty())
629✔
1591
                        return;
1592
                settings_.o._export_xml_stn_file= yesno_uint<UINT16, std::string>(val);
629✔
1593
        }
1594
        else if (boost::iequals(var, EXPORT_DNA_STN_FILE))
11,320✔
1595
        {
1596
                if (val.empty())
629✔
1597
                        return;
1598
                settings_.o._export_dna_stn_file = yesno_uint<UINT16, std::string>(val);
629✔
1599
        }
1600
        else if (boost::iequals(var, EXPORT_SNX_FILE))
10,691✔
1601
        {
1602
                if (val.empty())
629✔
1603
                        return;
1604
                settings_.o._export_snx_file = yesno_uint<UINT16, std::string>(val);
629✔
1605
        }
1606
        // ???
1607
        // EXPORT_DISCONT_FILE = "export-discont-file";
1608
        
1609
}
1610
        
1611
//void CDnaProjectFile::LoadSettingPlot(const std::string& var, std::string& val)
1612
//{
1613
//}
1614
//        
1615
//void CDnaProjectFile::LoadSettingDisplay(const std::string& var, std::string& val)
1616
//{
1617
//}
1618

1619
template <typename T>
NEW
1620
void CDnaProjectFile::AddOptionValue(std::ostream& os, const char* const option, const T& value) {
×
1621
        os << " --" << option << " " << value;
×
1622
}
×
1623

1624
template <typename T>
NEW
1625
void CDnaProjectFile::AddDefaultValue(std::ostream& os, const T& value)
×
1626
{
1627
        os << " " << value;
×
1628
}
×
1629

1630
template <typename T, typename U>
1631
void CDnaProjectFile::PrintRecord(std::ostream& os, const T& variable, const U& value) {
68,474✔
1632

1633
        PrintVariable(os, variable);
68,474✔
1634
        PrintValue(os, value);
68,474✔
1635
}
68,474✔
1636
        
1637

1638
template <typename T>
1639
void CDnaProjectFile::PrintVariable(std::ostream& os, const T& variable) {
68,474✔
1640
        // width of 35
1641
        os << std::setw(PRINT_VAR_PAD) << std::left << variable;
68,474✔
1642
}
68,474✔
1643
        
1644

1645
template <typename T>
1646
void CDnaProjectFile::PrintValue(std::ostream& os, const T& value) {
68,474✔
1647
        // width of 45
1648
        os << std::setw(PRINT_VAL_PAD) << std::left << value << std::endl;
68,474✔
1649
}
68,474✔
1650
        
1651

NEW
1652
std::string CDnaProjectFile::FormCommandLineOptionsStringImport()
×
1653
{
NEW
1654
        std::stringstream options;
×
1655
        //////////////////////////////////////////////////////
1656
        // General settings
1657
        AddDefaultValue(options, FormCommandLineOptionsStringGeneral());
×
1658
        
1659
        //////////////////////////////////////////////////////
1660
        // Import settings
1661
        // files
1662
        for (_it_vstr_const _it_tmp(settings_.i.input_files.begin());
×
1663
                _it_tmp!=settings_.i.input_files.end(); ++_it_tmp)
×
NEW
1664
                AddDefaultValue<std::string>(options, 
×
NEW
1665
                        leafStr<std::string>(trimstr<std::string>(_it_tmp->c_str())));
×
1666
        
1667

1668
        return options.str();
×
1669
}
×
1670
        
NEW
1671
std::string CDnaProjectFile::FormCommandLineOptionsStringGeneral()
×
1672
{
NEW
1673
        std::stringstream options;
×
1674
        //////////////////////////////////////////////////////
1675
        // General settings
1676
        // project file
NEW
1677
        AddOptionValue<std::string>(options, PROJECT_FILE, settings_.g.project_file);
×
1678
        // network name
NEW
1679
        AddOptionValue<std::string>(options, NETWORK_NAME, settings_.g.network_name);
×
1680
        // verbose
1681
        AddOptionValue<UINT16>(options, VERBOSE, settings_.g.verbose);
×
1682
        // verbose
1683
        AddOptionValue<UINT16>(options, QUIET, settings_.g.quiet);
×
1684

1685
        return options.str();
×
1686
}
×
1687
        
1688
void CDnaProjectFile::PrintProjectFile()
585✔
1689
{
1690
        std::ofstream dnaproj_file;
585✔
1691

1692
        std::stringstream err_msg;
585✔
1693
        err_msg << "PrintProjectFile(): An error was encountered when opening " << 
585✔
1694
                settings_.g.project_file << "." << std::endl;
585✔
1695

1696
        try {
585✔
1697
                // create binary aml file.  Throws runtime_error on failure.
1698
                file_opener(dnaproj_file, settings_.g.project_file,
585✔
1699
                        std::ios::out, ascii);
1700
        }
NEW
1701
        catch (const std::runtime_error& e) {
×
1702
                err_msg << e.what();
×
NEW
1703
                throw boost::enable_current_exception(std::runtime_error(err_msg.str()));
×
1704
        }
×
1705
        catch (...) {
×
NEW
1706
                throw boost::enable_current_exception(std::runtime_error(err_msg.str()));
×
1707
        }
×
1708

1709
        err_msg.str("");
1,755✔
1710
        err_msg << "PrintProjectFile(): An error was encountered when writing to " << 
585✔
1711
                settings_.g.project_file << "." << std::endl;
585✔
1712

1713
        std::stringstream ss;
585✔
1714

1715
        // Write header line
1716
        dnaproj_header(dnaproj_file, settings_.g.network_name + " project file");
585✔
1717
        dnaproj_file << std::endl << std::endl;
585✔
1718

1719
        ////////////////////////////////////////////////////////////////////////////////////////////////
1720
        // #general
1721
        ss.str("");
1,755✔
1722
        ss << section_general << " (" << PRINT_VAR_PAD << ")";
585✔
1723
        PrintRecord(dnaproj_file, ss.str(), "VALUE");
585✔
1724
        dnaproj_file << OUTPUTLINE << std::endl;
585✔
1725
        
1726
        PrintRecord(dnaproj_file, NETWORK_NAME, settings_.g.network_name);                                                                // network name
585✔
1727
        PrintRecord(dnaproj_file, INPUT_FOLDER, boost::filesystem::system_complete(settings_.g.input_folder).string());        // Path containing all input files
1,170✔
1728
        PrintRecord(dnaproj_file, OUTPUT_FOLDER, boost::filesystem::system_complete(settings_.g.output_folder).string());        // Path for all output files
1,170✔
1729
        PrintRecord(dnaproj_file, VERBOSE, settings_.g.verbose);                                                                                // Give detailed information about what dnainterop is doing.
585✔
1730
                                                                                                                                                                                                        // 0: No information (default)
1731
                                                                                                                                                                                                        // 1: Helpful information
1732
                                                                                                                                                                                                        // 2: Extended information\n3: Debug level information
1733
        PrintRecord(dnaproj_file, QUIET, yesno_string(settings_.g.quiet));                                                                // Run quietly?
585✔
1734
        PrintRecord(dnaproj_file, PROJECT_FILE, boost::filesystem::system_complete(settings_.g.project_file).string());        // project file
1,170✔
1735
        PrintRecord(dnaproj_file, DYNADJUST_LOG_FILE, boost::filesystem::system_complete(settings_.g.log_file).string());        // dynadjust log file
1,170✔
1736
        
1737
        dnaproj_file << std::endl;
585✔
1738

1739
        ////////////////////////////////////////////////////////////////////////////////////////////////
1740
        // #import
1741
        ss.str("");
1,755✔
1742
        ss << section_import << " (" << PRINT_VAR_PAD << ")";
585✔
1743
        PrintRecord(dnaproj_file, ss.str(), "VALUE");
585✔
1744
        dnaproj_file << OUTPUTLINE << std::endl;
585✔
1745
        
1746
        // Input files
1747
        for_each (settings_.i.input_files.begin(), settings_.i.input_files.end(),
585✔
1748
                [&dnaproj_file, this] (std::string file) {
1,199✔
1749
                        PrintRecord(dnaproj_file, IMPORT_FILE, leafStr<std::string>(file.c_str()));
3,597✔
1750
        });
1,199✔
1751

1752
        // geoid file
1753
        PrintRecord(dnaproj_file, IMPORT_GEO_FILE, 
585✔
1754
                (settings_.i.geo_file.empty() ? " " : leafStr<std::string>(settings_.i.geo_file)));
1,170✔
1755

1756
        // reference frame settings
1757
        PrintRecord(dnaproj_file, REFERENCE_FRAME, settings_.i.reference_frame);
585✔
1758
        PrintRecord(dnaproj_file, EPOCH, settings_.i.epoch);
585✔
1759
        PrintRecord(dnaproj_file, OVERRIDE_INPUT_FRAME, 
585✔
1760
                yesno_string(settings_.i.override_input_rfame));
585✔
1761

1762
        // data screening
1763
        PrintRecord(dnaproj_file, BOUNDING_BOX, settings_.i.bounding_box);
585✔
1764
        PrintRecord(dnaproj_file, GET_MSRS_TRANSCENDING_BOX, 
585✔
1765
                yesno_string(settings_.i.include_transcending_msrs));
585✔
1766
        
1767
        PrintRecord(dnaproj_file, INCLUDE_STN_ASSOC_MSRS,
585✔
1768
                (settings_.i.stn_associated_msr_include.empty() ? "no" : settings_.i.stn_associated_msr_include));
1,170✔
1769
        PrintRecord(dnaproj_file, EXCLUDE_STN_ASSOC_MSRS,
585✔
1770
                (settings_.i.stn_associated_msr_exclude.empty() ? "no" : settings_.i.stn_associated_msr_exclude));
1,170✔
1771
        PrintRecord(dnaproj_file, SPLIT_CLUSTERS,
585✔
1772
                yesno_string(settings_.i.split_clusters));        
585✔
1773
        PrintRecord(dnaproj_file, IMPORT_SEG_BLOCK,
585✔
1774
                (settings_.i.import_block ? val_uint<std::string, UINT32>(settings_.i.import_block_number) : "no"));
1,170✔
1775
        PrintRecord(dnaproj_file, SEG_FILE, 
585✔
1776
                (settings_.i.seg_file.empty() ? " " : leafStr<std::string>(settings_.i.seg_file)));
1,170✔
1777
        PrintRecord(dnaproj_file, PREFER_X_MSR_AS_G, 
585✔
1778
                yesno_string(settings_.i.prefer_single_x_as_g));        
585✔
1779
        
1780
        PrintRecord(dnaproj_file, INCLUDE_MSRS, settings_.i.include_msrs);
585✔
1781
        PrintRecord(dnaproj_file, EXCLUDE_MSRS, settings_.i.exclude_msrs);                                                        
585✔
1782
        PrintRecord(dnaproj_file, STATION_RENAMING_FILE,
585✔
1783
                leafStr<std::string>(settings_.i.stn_renamingfile));                                                
585✔
1784
        PrintRecord(dnaproj_file, STATION_DISCONTINUITY_FILE,
585✔
1785
                leafStr<std::string>(settings_.i.stn_discontinuityfile));                                                
585✔
1786
        PrintRecord(dnaproj_file, TEST_NEARBY_STNS,
585✔
1787
                yesno_string(settings_.i.search_nearby_stn));                                                
585✔
1788
        PrintRecord(dnaproj_file, TEST_NEARBY_STN_DIST, settings_.i.search_stn_radius);                                        
585✔
1789
        PrintRecord(dnaproj_file, TEST_SIMILAR_GNSS_MSRS,
585✔
1790
                yesno_string(settings_.i.search_similar_msr_gx));                                                
585✔
1791
        PrintRecord(dnaproj_file, TEST_SIMILAR_MSRS,
585✔
1792
                yesno_string(settings_.i.search_similar_msr));
585✔
1793
        PrintRecord(dnaproj_file, IGNORE_INSUFFICIENT_MSRS,
585✔
1794
                yesno_string(settings_.i.ignore_insufficient_msrs));
585✔
1795
        PrintRecord(dnaproj_file, IGNORE_SIMILAR_MSRS,
585✔
1796
                yesno_string(settings_.i.ignore_similar_msr));                                        
585✔
1797
        PrintRecord(dnaproj_file, REMOVE_IGNORED_MSRS,
585✔
1798
                yesno_string(settings_.i.remove_ignored_msr));                                        
585✔
1799
        PrintRecord(dnaproj_file, FLAG_UNUSED_STNS,
585✔
1800
                yesno_string(settings_.i.flag_unused_stn));                                                
585✔
1801
        PrintRecord(dnaproj_file, TEST_INTEGRITY,
585✔
1802
                yesno_string(settings_.i.test_integrity));                                                
585✔
1803
        
1804
        // GNSS variance matrix scaling
1805
        PrintRecord(dnaproj_file, VSCALE, settings_.i.vscale);                                
585✔
1806
        PrintRecord(dnaproj_file, PSCALE, settings_.i.pscale);                                
585✔
1807
        PrintRecord(dnaproj_file, LSCALE, settings_.i.lscale);                                
585✔
1808
        PrintRecord(dnaproj_file, HSCALE, settings_.i.hscale);                                
585✔
1809
        PrintRecord(dnaproj_file, SCALAR_FILE, leafStr<std::string>(settings_.i.scalar_file));
585✔
1810

1811
        // export options
1812
        PrintRecord(dnaproj_file, EXPORT_XML_FILES, 
585✔
1813
                yesno_string(settings_.i.export_dynaml));                                                // Create DynaML output file
585✔
1814
        PrintRecord(dnaproj_file, EXPORT_SINGLE_XML_FILE, 
585✔
1815
                yesno_string(settings_.i.export_single_xml_file));                                // Create single station and measurement DynaML output files
585✔
1816
        PrintRecord(dnaproj_file, EXPORT_DNA_FILES, 
585✔
1817
                yesno_string(settings_.i.export_dna_files));
585✔
1818
        PrintRecord(dnaproj_file, EXPORT_ASL_FILE,
585✔
1819
                yesno_string(settings_.i.export_asl_file));
585✔
1820
        PrintRecord(dnaproj_file, EXPORT_AML_FILE, 
585✔
1821
                yesno_string(settings_.i.export_aml_file));
585✔
1822
        PrintRecord(dnaproj_file, EXPORT_MAP_FILE,
585✔
1823
                yesno_string(settings_.i.export_map_file));
585✔
1824
        PrintRecord(dnaproj_file, SIMULATE_MSR_FILE, 
585✔
1825
                yesno_string(settings_.i.simulate_measurements));
585✔
1826

1827
        dnaproj_file << std::endl;
585✔
1828
        
1829
        ////////////////////////////////////////////////////////////////////////////////////////////////
1830
        // #reftran
1831
        ss.str("");
1,755✔
1832
        ss << section_reftran << " (" << PRINT_VAR_PAD << ")";
585✔
1833
        PrintRecord(dnaproj_file, ss.str(), "VALUE");
585✔
1834
        dnaproj_file << OUTPUTLINE << std::endl;
585✔
1835
        
1836
        PrintRecord(dnaproj_file, REFERENCE_FRAME, settings_.r.reference_frame);
585✔
1837
        PrintRecord(dnaproj_file, EPOCH, settings_.r.epoch);
585✔
1838

1839
        PrintRecord(dnaproj_file, TECTONIC_PLATE_MODEL_OPTION, settings_.r.plate_model_option);                                        // Plate motion model option
585✔
1840
        PrintRecord(dnaproj_file, TECTONIC_PLATE_BDY_FILE, leafStr<std::string>(settings_.r.tpb_file));                                // Tectonic plate boundary file
585✔
1841
        PrintRecord(dnaproj_file, TECTONIC_PLATE_POLE_FILE, leafStr<std::string>(settings_.r.tpp_file));                                // Tectonic plate pole file
585✔
1842
        
1843
        dnaproj_file << std::endl;
585✔
1844
        
1845
        ////////////////////////////////////////////////////////////////////////////////////////////////
1846
        // #geoid
1847
        ss.str("");
1,755✔
1848
        ss << section_geoid << " (" << PRINT_VAR_PAD << ")";
585✔
1849
        PrintRecord(dnaproj_file, ss.str(), "VALUE");
585✔
1850
        dnaproj_file << OUTPUTLINE << std::endl;
585✔
1851

1852
        // Output configured to populate binary station files
1853
        PrintRecord(dnaproj_file, NTV2_FILEPATH, boost::filesystem::system_complete(settings_.n.ntv2_geoid_file).string());                                        // Full file path to geoid file
1,170✔
1854
        
1855
        PrintRecord(dnaproj_file, METHOD, settings_.n.interpolation_method);
585✔
1856
        PrintRecord(dnaproj_file, DDEG_FORMAT, settings_.n.coordinate_format);
585✔
1857
        PrintRecord(dnaproj_file, DIRECTION, settings_.n.ellipsoid_to_ortho);
585✔
1858
        //PrintRecord(dnaproj_file, CONVERT_BST_HT,
1859
        //        yesno_string(settings_.n.convert_heights));
1860
        PrintRecord(dnaproj_file, EXPORT_GEO_FILE,
585✔
1861
                yesno_string(settings_.n.export_dna_geo_file));
585✔
1862
        
1863
        dnaproj_file << std::endl;
585✔
1864

1865
        ////////////////////////////////////////////////////////////////////////////////////////////////
1866
        // #segment
1867
        ss.str("");
1,755✔
1868
        ss << section_segment << " (" << PRINT_VAR_PAD << ")";
585✔
1869
        PrintRecord(dnaproj_file, ss.str(), "VALUE");
585✔
1870
        dnaproj_file << OUTPUTLINE << std::endl;
585✔
1871
        
1872
        PrintRecord(dnaproj_file, NET_FILE, leafStr<std::string>(settings_.s.net_file));                                // Starting stations file
585✔
1873
        PrintRecord(dnaproj_file, SEG_FILE, leafStr<std::string>(settings_.s.seg_file));                                // Segmentation output file
585✔
1874
        PrintRecord(dnaproj_file, SEG_MIN_INNER_STNS, settings_.s.min_inner_stations);                        // Minimum number of inner stations per block
585✔
1875
        PrintRecord(dnaproj_file, SEG_THRESHOLD_STNS, settings_.s.max_total_stations);                        // Maximum number of total stations per block
585✔
1876
        PrintRecord(dnaproj_file, SEG_FORCE_CONTIGUOUS,
585✔
1877
                yesno_string(settings_.s.force_contiguous_blocks));
585✔
1878

1879
        // Stations to be incorporated within the first block.
1880
        PrintRecord(dnaproj_file, SEG_STARTING_STN, settings_.s.seg_starting_stns);        
585✔
1881

1882
        dnaproj_file << std::endl;
585✔
1883

1884
        ////////////////////////////////////////////////////////////////////////////////////////////////
1885
        // #adjust
1886
        ss.str("");
1,755✔
1887
        ss << section_adjust << " (" << PRINT_VAR_PAD << ")";
585✔
1888
        PrintRecord(dnaproj_file, ss.str(), "VALUE");
585✔
1889
        dnaproj_file << OUTPUTLINE << std::endl;
585✔
1890

1891
        PrintRecord(dnaproj_file, SEG_FILE, leafStr<std::string>(settings_.a.seg_file));                                // Starting stations file
585✔
1892
        PrintRecord(dnaproj_file, COMMENTS, settings_.a.comments);                                                                // Starting stations file
585✔
1893
        
1894
        PrintRecord(dnaproj_file, ADJUSTMENT_MODE, adjustmentMode<std::string, UINT32>(settings_.a.adjust_mode));
585✔
1895

1896
        PrintRecord(dnaproj_file, MODE_PHASED_MT, 
585✔
1897
                yesno_string(settings_.a.multi_thread));
585✔
1898
        PrintRecord(dnaproj_file, STAGED_ADJUSTMENT, 
585✔
1899
                yesno_string(settings_.a.stage));
585✔
1900
        
1901
        PrintRecord(dnaproj_file, CONF_INTERVAL, settings_.a.confidence_interval);                                // Confidence interval
585✔
1902
        PrintRecord(dnaproj_file, ITERATION_THRESHOLD, settings_.a.iteration_threshold);                // Threshold to halt iterations
585✔
1903
        PrintRecord(dnaproj_file, MAX_ITERATIONS, settings_.a.max_iterations);                                        // Number of iteration before a solution is adopted
585✔
1904
        PrintRecord(dnaproj_file, STN_CONSTRAINTS, settings_.a.station_constraints);                        
585✔
1905
        
1906
        ss.str("");
1,755✔
1907
        ss << std::fixed << std::setprecision(3) << settings_.a.free_std_dev;
585✔
1908
        PrintRecord(dnaproj_file, FREE_STN_SD, ss.str());                                                                                // SD for free stations
585✔
1909
        ss.str("");
1,755✔
1910
        ss << std::scientific << std::setprecision(4) << settings_.a.fixed_std_dev;
585✔
1911
        PrintRecord(dnaproj_file, FIXED_STN_SD, ss.str());                                                                                // SD for fixed stations
585✔
1912
        
1913
        //PrintRecord(dnaproj_file, LSQ_INVERSE_METHOD, settings_.a.inverse_method_lsq);                        // Least squares inverse method
1914

1915
        PrintRecord(dnaproj_file, SCALE_NORMAL_UNITY, 
585✔
1916
                yesno_string(settings_.a.scale_normals_to_unity));                                                                        // Scale normals to unity before inversion
585✔
1917
        PrintRecord(dnaproj_file, RECREATE_STAGE_FILES, 
585✔
1918
                yesno_string(settings_.a.recreate_stage_files));                                                                        // Recreate stage files
585✔
1919
        PrintRecord(dnaproj_file, PURGE_STAGE_FILES, 
585✔
1920
                yesno_string(settings_.a.purge_stage_files));                                                                                // Purge stage files
585✔
1921

1922
        PrintRecord(dnaproj_file, TYPE_B_GLOBAL, settings_.a.type_b_global);                                        // Global Type B uncertainties
585✔
1923
        PrintRecord(dnaproj_file, TYPE_B_FILE, leafStr<std::string>(settings_.a.type_b_file));                // Type B uncertainty file
585✔
1924
        
1925
        dnaproj_file << std::endl;
585✔
1926

1927
        ////////////////////////////////////////////////////////////////////////////////////////////////
1928
        // #output
1929
        ss.str("");
1,755✔
1930
        ss << section_output << " (" << PRINT_VAR_PAD << ")";
585✔
1931
        PrintRecord(dnaproj_file, ss.str(), "VALUE");
585✔
1932
        dnaproj_file << OUTPUTLINE << std::endl;
585✔
1933

1934
        PrintRecord(dnaproj_file, OUTPUT_MSR_TO_STN, 
585✔
1935
                yesno_string(settings_.o._msr_to_stn));
585✔
1936
        PrintRecord(dnaproj_file, OUTPUT_MSR_TO_STN_SORTBY, settings_.o._sort_msr_to_stn);
585✔
1937
        PrintRecord(dnaproj_file, OUTPUT_ADJ_STN_ITER, 
585✔
1938
                yesno_string(settings_.o._adj_stn_iteration));
585✔
1939
        PrintRecord(dnaproj_file, OUTPUT_ADJ_STAT_ITER, 
585✔
1940
                yesno_string(settings_.o._adj_stat_iteration));
585✔
1941
        PrintRecord(dnaproj_file, OUTPUT_ADJ_MSR_ITER, 
585✔
1942
                yesno_string(settings_.o._adj_msr_iteration));
585✔
1943
        PrintRecord(dnaproj_file, OUTPUT_CMP_MSR_ITER, 
585✔
1944
                yesno_string(settings_.o._cmp_msr_iteration));
585✔
1945
        PrintRecord(dnaproj_file, OUTPUT_ADJ_MSR, 
585✔
1946
                yesno_string(settings_.o._adj_msr_final));
585✔
1947
        PrintRecord(dnaproj_file, OUTPUT_ADJ_GNSS_UNITS, 
585✔
1948
                settings_.o._adj_gnss_units);        
585✔
1949
        PrintRecord(dnaproj_file, OUTPUT_ADJ_MSR_TSTAT, 
585✔
1950
                yesno_string(settings_.o._adj_msr_tstat));
585✔
1951

1952
        PrintRecord(dnaproj_file, OUTPUT_ADJ_MSR_SORTBY, settings_.o._sort_adj_msr);
585✔
1953

1954
        PrintRecord(dnaproj_file, OUTPUT_ADJ_MSR_DBID, 
585✔
1955
                yesno_string(settings_.o._database_ids));                        
585✔
1956
        
1957
        PrintRecord(dnaproj_file, OUTPUT_ADJ_MSR_BLOCKS, 
585✔
1958
                yesno_string(settings_.o._output_msr_blocks));                                
585✔
1959
        PrintRecord(dnaproj_file, OUTPUT_ADJ_STN_SORT_ORDER, 
585✔
1960
                yesno_string(settings_.o._sort_stn_file_order));                        
585✔
1961
        PrintRecord(dnaproj_file, OUTPUT_STN_COORD_TYPES, settings_.o._stn_coord_types);
585✔
1962
        PrintRecord(dnaproj_file, OUTPUT_ANGULAR_TYPE_STN, settings_.o._angular_type_stn);
585✔
1963
        PrintRecord(dnaproj_file, OUTPUT_STN_CORR, 
585✔
1964
                yesno_string(settings_.o._stn_corr));
585✔
1965
        PrintRecord(dnaproj_file, OUTPUT_PRECISION_METRES_STN, settings_.o._precision_metres_stn);        
585✔
1966
        PrintRecord(dnaproj_file, OUTPUT_PRECISION_SECONDS_STN, settings_.o._precision_seconds_stn);
585✔
1967
        PrintRecord(dnaproj_file, OUTPUT_PRECISION_METRES_MSR, settings_.o._precision_metres_msr);        
585✔
1968
        PrintRecord(dnaproj_file, OUTPUT_PRECISION_SECONDS_MSR, settings_.o._precision_seconds_msr);
585✔
1969
        PrintRecord(dnaproj_file, OUTPUT_ANGULAR_TYPE_MSR, settings_.o._angular_type_msr);
585✔
1970
        PrintRecord(dnaproj_file, OUTPUT_DMS_FORMAT_MSR, settings_.o._dms_format_msr);                                
585✔
1971
        PrintRecord(dnaproj_file, OUTPUT_POS_UNCERTAINTY, 
585✔
1972
                yesno_string(settings_.o._positional_uncertainty));
585✔
1973
        PrintRecord(dnaproj_file, OUTPUT_APU_CORRELATIONS, 
585✔
1974
                yesno_string(settings_.o._output_pu_covariances));                
585✔
1975
        
1976
        PrintRecord(dnaproj_file, OUTPUT_APU_UNITS, 
585✔
1977
                settings_.o._apu_vcv_units);
585✔
1978

1979
        PrintRecord(dnaproj_file, OUTPUT_STN_COR_FILE, 
585✔
1980
                yesno_string(settings_.o._init_stn_corrections));
585✔
1981
        
1982
        ss.str("");
1,755✔
1983
        ss << std::fixed << std::setprecision(3) << settings_.o._hz_corr_threshold;
585✔
1984
        PrintRecord(dnaproj_file, HZ_CORR_THRESHOLD, ss.str());                                
585✔
1985
        ss.str("");
1,755✔
1986
        ss << std::fixed << std::setprecision(3) << settings_.o._vt_corr_threshold;
585✔
1987
        PrintRecord(dnaproj_file, VT_CORR_THRESHOLD, ss.str());                                
585✔
1988
        
1989
        PrintRecord(dnaproj_file, EXPORT_XML_STN_FILE, 
585✔
1990
                yesno_string(settings_.o._export_xml_stn_file));                                        
585✔
1991
        PrintRecord(dnaproj_file, EXPORT_DNA_STN_FILE, 
585✔
1992
                yesno_string(settings_.o._export_dna_stn_file));                                        
585✔
1993
        PrintRecord(dnaproj_file, EXPORT_SNX_FILE, 
585✔
1994
                yesno_string(settings_.o._export_snx_file));                                        
585✔
1995
        
1996
        dnaproj_file << std::endl;
585✔
1997

1998
        ////////////////////////////////////////////////////////////////////////////////////////////////
1999
        // #plot
2000
        ss.str("");
1,755✔
2001
        ss << section_plot << " (" << PRINT_VAR_PAD << ")";
585✔
2002
        PrintRecord(dnaproj_file, ss.str(), "VALUE");
585✔
2003
        dnaproj_file << OUTPUTLINE << std::endl;
585✔
2004
        
2005
        dnaproj_file << std::endl;
585✔
2006

2007
        dnaproj_file.close();
585✔
2008
}
585✔
2009

2010

2011

2012
}        // 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