• 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

90.44
/dynadjust/dynadjust/dnaadjustwrapper/dnaadjustwrapper.cpp
1
//============================================================================
2
// Name         : dnaadjustwrapper.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 Adjustment library Executable
21
//============================================================================
22

23
#include <dynadjust/dnaadjustwrapper/dnaadjustwrapper.hpp>
24
#include <dynadjust/dnaadjustwrapper/dnaadjustprogress.hpp>
25

26
extern bool running;
27
extern boost::mutex cout_mutex;
28

29
using namespace dynadjust;
30
using namespace dynadjust::epsg;
31

32
void PrintSummaryMessage(dna_adjust* netAdjust, const project_settings* p, boost::posix_time::milliseconds *elapsed_time)
20✔
33
{
34
        if (p->g.quiet)
20✔
35
                return;
1✔
36

37
        cout_mutex.lock();
20✔
38
        std::cout.flush();
20✔
39
        UINT32 currentIteration(0);
20✔
40

41
        // any messages left
42
        while (netAdjust->NewMessagesAvailable())
58✔
43
        {
44
                if (!netAdjust->GetMessageIteration(currentIteration))
38✔
45
                        break;
46
                std::stringstream ss("");
76✔
47
                ss << "  Iteration " << std::right << std::setw(2) << std::fixed << std::setprecision(0) << currentIteration;
38✔
48
                ss << ", max station corr: " << std::right << std::setw(12) << netAdjust->GetMaxCorrection(currentIteration) << std::endl;
76✔
49
                std::cout << PROGRESS_BACKSPACE_28 << std::setw(28) << std::left << ss.str();
38✔
50
        }
38✔
51

52
        if (p->a.report_mode)
20✔
53
        {
54
                std::cout << "+ Printing results of last adjustment only" << std::endl;
1✔
55
                cout_mutex.unlock();
1✔
56
                return;
1✔
57
        }
58

59
        std::cout << std::left << "+ Done." << std::endl;
19✔
60

61
        UINT32 block_count(netAdjust->blockCount());
19✔
62
        std::string block_str(" block");
19✔
63
        if (block_count > 1)
19✔
64
                block_str.append("s");
9✔
65
        block_str.append(".");
19✔
66
        
67
        switch (p->a.adjust_mode)
19✔
68
        {
69
        case Phased_Block_1Mode:
9✔
70
        case PhasedMode:
9✔
71
                if (netAdjust->GetStatus() == ADJUST_SUCCESS)
9✔
72
                        std::cout << "+ Successfully adjusted " << block_count << block_str;
7✔
73
                else
74
                        std::cout << "+ Attempted to adjust " << netAdjust->blockCount() << block_str;
2✔
75
                std::cout << std::endl;
9✔
76
        }
77
        
78
        
79
        std::cout << "+ Solution: ";
19✔
80

81
        if (netAdjust->GetStatus() != ADJUST_SUCCESS)
19✔
82
        {        
83
                std::cout << "failed to converge after ";
2✔
84
                if (p->a.adjust_mode == Phased_Block_1Mode ||
2✔
85
                        p->a.max_iterations == 1)
1✔
86
                        std::cout << "one iteration." << std::endl;
1✔
87
                else
88
                        std::cout << p->a.max_iterations << " iterations." << std::endl;
1✔
89

90
                if (netAdjust->GetStatus() > ADJUST_THRESHOLD_EXCEEDED)
2✔
91
                {
NEW
92
                        std::cout << std::endl << "+ Open " << leafStr<std::string>(p->o._adj_file) << " to view the adjustment details." << std::endl << std::endl;
×
93
                        cout_mutex.unlock();
×
94
                        return;
×
95
                }                
96
        }
97
        else
98
        {
99
                switch (p->a.adjust_mode)
17✔
100
                {
101
                case Phased_Block_1Mode:
×
NEW
102
                        std::cout << "estimates solved for Block 1 only." << std::endl <<
×
NEW
103
                                 std::endl << 
×
NEW
104
                                "- Warning: Depending on the quality of the apriori station estimates, further" << std::endl <<
×
NEW
105
                                "  iterations may be needed. --block1-phased mode should only be used once" << std::endl <<
×
NEW
106
                                "  rigorous estimates have been produced for the entire network." << std::endl << std::endl;
×
107
                        break;
108
                default:
17✔
109
                        std::cout << "converged after " << netAdjust->CurrentIteration() << " iteration"; 
17✔
110
                        if (netAdjust->CurrentIteration() > 1)
17✔
111
                                std::cout << "s";
8✔
112
                        std::cout << "." << std::endl;
17✔
113
                }
114
        }
115

116
        std::cout << formatedElapsedTime<std::string>(elapsed_time, "+ Network adjustment took ") << std::endl;
76✔
117
        cout_mutex.unlock();
19✔
118
        
119
}
19✔
120

121
void SerialiseVarianceMatrices(dna_adjust* netAdjust, const project_settings* p)
19✔
122
{
123
        // No need to facilitate serialising if network adjustment is in stage,
124
        // as this will already be taken care of
125
        if (p->a.stage)
19✔
126
                return;
127

128
        if (!p->g.quiet)
15✔
129
        {
130
                std::cout << "+ Serialising adjustment matrices... ";
15✔
131
                std::cout.flush();
15✔
132
        }
133

134
        netAdjust->SerialiseAdjustedVarianceMatrices();
15✔
135

136
        if (!p->g.quiet)
15✔
137
        {
138
                std::cout << "done." << std::endl;
15✔
139
                std::cout.flush();
15✔
140
        }
141

142
        
143
}
144
        
145

146
void DeserialiseVarianceMatrices(dna_adjust* netAdjust, const project_settings* p)
1✔
147
{
148
        // No need to facilitate serialising if network adjustment is in stage,
149
        // as this will already be taken care of
150
        if (p->a.stage)
1✔
151
                return;
152

153
        netAdjust->DeSerialiseAdjustedVarianceMatrices();
1✔
154
}
155
        
156

157
void GenerateStatistics(dna_adjust* netAdjust, const project_settings* p)
20✔
158
{
159
        // Generate statistics
160
        // Don't produce statistics only for block 1 only adjustments
161
        if (p->a.adjust_mode != Phased_Block_1Mode)
20✔
162
        {
163
                if (!p->g.quiet)
19✔
164
                {
165
                        std::cout << "+ Generating statistics...";
19✔
166
                        std::cout.flush();
19✔
167
                }
168
                netAdjust->GenerateStatistics();
19✔
169
                if (!p->g.quiet)
19✔
170
                {
171
                        std::cout << " done." << std::endl;
19✔
172

173
                        std::cout << "+ Adjustment results:" << std::endl << std::endl;
19✔
174
                        std::cout << "+" << OUTPUTLINE << std::endl;
19✔
175
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Number of unknown parameters" << std::fixed << std::setprecision(0) << netAdjust->GetUnknownsCount();
19✔
176
                        if (netAdjust->GetAllFixed())
19✔
NEW
177
                                std::cout << "  (All stations held constrained)";
×
178
                        std::cout << std::endl;
19✔
179

180
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Number of measurements" << std::fixed << std::setprecision(0) << netAdjust->GetMeasurementCount();
19✔
181
                        
182
                        if (netAdjust->GetPotentialOutlierCount() > 0)
19✔
183
                        {
184
                                std::cout << "  (" << netAdjust->GetPotentialOutlierCount() << " potential outlier";
18✔
185
                                if (netAdjust->GetPotentialOutlierCount() > 1)
18✔
186
                                        std::cout << "s";
18✔
187
                                std::cout << ")";
18✔
188
                        }
189
                        std::cout << std::endl;
19✔
190
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Degrees of freedom" << std::fixed << std::setprecision(0) << netAdjust->GetDegreesOfFreedom() << std::endl;
19✔
191
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Chi squared" << std::fixed << std::setprecision(2) << netAdjust->GetChiSquared() << std::endl;
19✔
192
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Rigorous sigma zero" << std::fixed << std::setprecision(3) << netAdjust->GetSigmaZero() << std::endl;
19✔
193
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Global (Pelzer) Reliability" << std::fixed << std::setw(8) << std::setprecision(3) << netAdjust->GetGlobalPelzerRel() << "(excludes non redundant measurements)" << std::endl << std::endl;
19✔
194
                
195
                        std::stringstream ss("");
38✔
196
                        ss << std::left << "  Chi-Square test (" << std::setprecision(1) << std::fixed << p->a.confidence_interval << "%)";
19✔
197
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << ss.str();
19✔
198
                        ss.str("");
57✔
199
                        ss << std::fixed << std::setprecision(3) << 
19✔
200
                                netAdjust->GetChiSquaredLowerLimit() << " < " << 
19✔
201
                                netAdjust->GetSigmaZero() << " < " <<
19✔
202
                                netAdjust->GetChiSquaredUpperLimit();
19✔
203
                        std::cout << std::setw(CHISQRLIMITS) << std::left << ss.str();
19✔
204
                        ss.str("");
57✔
205

206
                        if (netAdjust->GetDegreesOfFreedom() < 1)
19✔
UNCOV
207
                                ss << "NO REDUNDANCY";
×
208
                        else
209
                        {
210
                                ss << "*** ";
19✔
211
                                switch (netAdjust->GetTestResult())
19✔
212
                                {
213
                                case test_stat_pass: 
5✔
214
                                        ss << "PASSED";                // within upper and lower
5✔
215
                                        break;
216
                                case test_stat_warning:
5✔
217
                                        ss << "WARNING";        // less than lower limit
5✔
218
                                        break;
219
                                case test_stat_fail:
9✔
220
                                        ss << "FAILED";                // greater than upper limit
9✔
221
                                        break;
222
                                }
223
                                ss << " ***";
19✔
224
                        }
225

226
                        std::cout << std::setw(PASS_FAIL) << std::right << ss.str() << std::endl;        
19✔
227
                        std::cout << "+" << OUTPUTLINE << std::endl << std::endl;
19✔
228
                }
19✔
229
        }
230
        else
231
                std::cout << std::endl;
1✔
232
}
20✔
233

234
void PrintAdjustedMeasurements(dna_adjust* netAdjust, const project_settings* p)
20✔
235
{
236
        if (p->o._adj_msr_final)
20✔
237
        {
238
                if (!p->g.quiet)
12✔
239
                {
240
                        std::cout << "+ Printing adjusted measurements...";
12✔
241
                        std::cout.flush();
12✔
242
                }
243

244
                netAdjust->PrintAdjustedNetworkMeasurements();
12✔
245
                if (!p->g.quiet)
12✔
246
                        std::cout << " done." << std::endl;
12✔
247
        }
248
}
20✔
249

250
void PrintMeasurementstoStations(dna_adjust* netAdjust, const project_settings* p)
20✔
251
{
252
        // Print measurements to stations table
253
        if (p->o._msr_to_stn)
20✔
254
        {
255
                if (!p->g.quiet)
1✔
256
                {
257
                        std::cout << "+ Printing summary of measurements connected to each station...";
1✔
258
                        std::cout.flush();
1✔
259
                }
260
                netAdjust->PrintMeasurementsToStation();
1✔
261
                if (!p->g.quiet)
1✔
262
                        std::cout << " done." << std::endl;
1✔
263
        }
264
}
20✔
265

266
void PrintAdjustedNetworkStations(dna_adjust* netAdjust, const project_settings* p)
20✔
267
{
268
        // Print adjusted stations to ADJ file
269
        if (!p->g.quiet)
20✔
270
        {
271
                std::cout << "+ Printing adjusted station coordinates...";
20✔
272
                std::cout.flush();
20✔
273
        }
274
        netAdjust->PrintAdjustedNetworkStations();
20✔
275
        if (!p->g.quiet)
20✔
276
                std::cout << " done." << std::endl;
20✔
277
}
20✔
278

279
void PrintPositionalUncertainty(dna_adjust* netAdjust, const project_settings* p)
20✔
280
{
281
        // Print positional uncertainty
282
        if (p->o._positional_uncertainty)
20✔
283
        {
284
                if (!p->g.quiet)
6✔
285
                {
286
                        std::cout << "+ Printing positional uncertainty of adjusted coordinates...";
6✔
287
                        std::cout.flush();
6✔
288
                }
289
                // Print correlations as required
290
                netAdjust->PrintPositionalUncertainty();
6✔
291
                if (!p->g.quiet)
6✔
292
                        std::cout << " done." << std::endl;
6✔
293
        }
294
}
20✔
295

296
void PrintStationCorrections(dna_adjust* netAdjust, const project_settings* p)
20✔
297
{
298
        // Print corrections
299
        if (p->o._init_stn_corrections)
20✔
300
        {
301
                if (!p->g.quiet)
3✔
302
                {
303
                        std::cout << "+ Printing corrections to initial station coordinates...";
3✔
304
                        std::cout.flush();
3✔
305
                }
306
                netAdjust->PrintNetworkStationCorrections();
3✔
307
                if (!p->g.quiet)
3✔
308
                        std::cout << " done." << std::endl;
3✔
309
        }
310
}
20✔
311

312
void UpdateBinaryFiles(dna_adjust* netAdjust, const project_settings* p)
20✔
313
{
314
        // Update bst and bms files with adjustment results
315
        if (!p->g.quiet)
20✔
316
        {
317
                std::cout << "+ Updating binary station and measurement files...";
20✔
318
                std::cout.flush();
20✔
319
        }
320
        netAdjust->UpdateBinaryFiles();
20✔
321
        if (!p->g.quiet)
20✔
322
                std::cout << " done." << std::endl;
20✔
323
}
20✔
324

325
void ExportDynaML(dna_adjust* netAdjust, project_settings* p)
20✔
326
{
327
        // Output adjustment as XML stn
328
        if (p->o._export_xml_stn_file)
20✔
329
        {
330
                // single file for both stations and measurements
331
                p->o._xml_file = p->o._adj_file + ".stn.xml";
2✔
332
                                
333
                if (!p->g.quiet)
2✔
334
                        std::cout << "+ Serializing estimated coordinates to " << leafStr<std::string>(p->o._xml_file) << "... ";
6✔
335
                                
336
                // Export Stations file
337
                netAdjust->PrintEstimatedStationCoordinatestoDNAXML(p->o._xml_file, dynaml, 
2✔
338
                        (p->i.flag_unused_stn ? true : false));
2✔
339

340
                if (!p->g.quiet)
2✔
341
                        std::cout << "Done." << std::endl;
2✔
342
        }
343

344
        // Output adjustment as XML msr
345
        if (p->o._export_xml_msr_file)
20✔
346
        {
347
                // single file for both stations and measurements
348
                p->o._xml_file = p->o._adj_file + ".msr.xml";
3✔
349
                                
350
                if (!p->g.quiet)
3✔
351
                        std::cout << "+ Serializing estimated coordinates and uncertainties to " << leafStr<std::string>(p->o._xml_file) << "... ";
9✔
352
                                
353
                // Export Measurements file (exclude unused stations given 
354
                // they will not have been estimated)
355
                netAdjust->PrintEstimatedStationCoordinatestoDNAXML_Y(p->o._xml_file, dynaml);
3✔
356

357
                if (!p->g.quiet)
3✔
358
                        std::cout << "Done." << std::endl;
3✔
359
        }
360
}
20✔
361

362
void ExportDNA(dna_adjust* netAdjust, project_settings* p)
20✔
363
{
364
        // Print adjusted stations and measurements to DNA stn
365
        if (p->o._export_dna_stn_file)
20✔
366
        {
367
                std::string stnfilename(p->o._adj_file + ".stn");
2✔
368
                
369
                if (!p->g.quiet)
2✔
370
                        std::cout << "+ Serializing estimated coordinates to " << leafStr<std::string>(stnfilename) << "... ";
6✔
371
                                        
372
                // Export Station file
373
                netAdjust->PrintEstimatedStationCoordinatestoDNAXML(stnfilename, dna, 
2✔
374
                        (p->i.flag_unused_stn ? true : false));
2✔
375

376
                if (!p->g.quiet)
2✔
377
                        std::cout << "Done." << std::endl;
2✔
378
        }
2✔
379

380
        // Print adjusted stations and measurements to DNA msr
381
        if (p->o._export_dna_msr_file)
20✔
382
        {
383
                std::string msrfilename(p->o._adj_file + ".msr");
3✔
384
                
385
                if (!p->g.quiet)
3✔
386
                        std::cout << "+ Serializing estimated coordinates and uncertainties to " << leafStr<std::string>(msrfilename) << "... ";
9✔
387
                                        
388
                // Export Measurements file (exclude unused stations given 
389
                // they will not have been estimated)
390
                netAdjust->PrintEstimatedStationCoordinatestoDNAXML_Y(msrfilename, dna);
3✔
391

392
                if (!p->g.quiet)
3✔
393
                        std::cout << "Done." << std::endl;
3✔
394
        }
3✔
395
}
20✔
396

397
void ExportSinex(dna_adjust* netAdjust, const project_settings* p)
20✔
398
{
399
        // Print adjusted stations and measurements to SINEX
400
        if (p->o._export_snx_file)
20✔
401
        {
402
                std::string sinex_file;
2✔
403
                // Export to SINEX
404
                if (!p->g.quiet)
2✔
405
                        std::cout << "+ Printing station estimates and uncertainties to SINEX...";
2✔
406
                bool success(netAdjust->PrintEstimatedStationCoordinatestoSNX(sinex_file));
2✔
407

408
                // SomeFunc()
409
                if (!p->g.quiet)
2✔
410
                        std::cout << " done." << std::endl;
2✔
411

412
                if (!success)
2✔
413
                {
414
                        std::cout << "- Warning: The SINEX export process produced some warnings." << std::endl;
2✔
415
                        switch (p->a.adjust_mode)
2✔
416
                        {
417
                        case PhasedMode:
2✔
418
                                sinex_file = findandreplace(sinex_file, std::string("-block1"), std::string("-block*"));
8✔
419
                        }
420

421
                        std::cout << "  See " << leafStr<std::string>(sinex_file) << ".err for details." << std::endl; 
6✔
422
                }
423
        }
2✔
424
}
20✔
425

426
int ParseCommandLineOptions(const int& argc, char* argv[], const boost::program_options::variables_map& vm, project_settings& p)
28✔
427
{
428
        // capture command line arguments
429
        for (int cmd_arg(0); cmd_arg<argc; ++cmd_arg)
242✔
430
        {
431
                 p.a.command_line_arguments += argv[cmd_arg];
214✔
432
                 p.a.command_line_arguments += " ";
214✔
433
        }
434

435
        if (vm.count(PROJECT_FILE))
56✔
436
        {
437
                if (boost::filesystem::exists(p.g.project_file))
4✔
438
                {
439
                        try {
1✔
440
                                CDnaProjectFile projectFile(p.g.project_file, adjustSetting);
1✔
441
                                p = projectFile.GetSettings();
1✔
442
                        }
×
NEW
443
                        catch (const std::runtime_error& e) {
×
NEW
444
                                std::cout << std::endl << "- Error: " << e.what() << std::endl;
×
445
                                return EXIT_FAILURE;
×
446
                        }
×
447
                        
448
                        return EXIT_SUCCESS;
1✔
449
                }
450

451
                std::cout << std::endl << "- Error: project file " << p.g.project_file << " does not exist." << std::endl << std::endl;
1✔
452
                return EXIT_FAILURE;
1✔
453
        }
454

455
        if (!vm.count(NETWORK_NAME))
52✔
456
        {
457
                std::cout << std::endl << "- Nothing to do - no network name specified. " << std::endl << std::endl;  
1✔
458
                return EXIT_FAILURE;
1✔
459
        }
460

461
        p.g.project_file = formPath<std::string>(p.g.output_folder, p.g.network_name, "dnaproj");
75✔
462

463
        if (boost::filesystem::exists(p.g.project_file))
50✔
464
        {
465
                // update import settings from dnaproj file
466
                try {
24✔
467
                        CDnaProjectFile projectFile(p.g.project_file, importSetting);
24✔
468
                        p.i = projectFile.GetSettings().i;
24✔
469
                }
24✔
470
                catch (...) {
×
471
                        // do nothing
472
                }
×
473

474
                // update geoid file name from dnaproj file (blank if geoid was not executed)
475
                try {
24✔
476
                        CDnaProjectFile projectFile(p.g.project_file, geoidSetting);
24✔
477
                        p.n = projectFile.GetSettings().n;
7✔
478
                }
7✔
479
                catch (...) {
17✔
480
                        // do nothing
481
                }
17✔
482

483
                // update reftran settings from dnaproj file
484
                // Note, if reftran was not executed, reference frame and epoch will be set to 
485
                // the frame and epoch captured on import.
486
                try {
24✔
487
                        CDnaProjectFile projectFile(p.g.project_file, reftranSetting);
24✔
488
                        p.r = projectFile.GetSettings().r;
24✔
489
                }
24✔
490
                catch (...) {
×
491
                        // do nothing
492
                }
×
493
        }
494

495
        // binary station file location (output)
496
        if (vm.count(BIN_STN_FILE))
50✔
NEW
497
                p.a.bst_file = formPath<std::string>(p.g.input_folder, p.a.bst_file);
×
498
        else
499
                p.a.bst_file = formPath<std::string>(p.g.output_folder, p.g.network_name, "bst");
75✔
500
        
501
        // binary station file location (output)
502
        if (vm.count(BIN_MSR_FILE))
50✔
NEW
503
                p.a.bms_file = formPath<std::string>(p.g.input_folder, p.a.bms_file);
×
504
        else
505
                p.a.bms_file = formPath<std::string>(p.g.output_folder, p.g.network_name, "bms");
75✔
506

507
        if (!boost::filesystem::exists(p.a.bst_file) || !boost::filesystem::exists(p.a.bms_file))
74✔
508
        {
509
                cout_mutex.lock();
1✔
510
                std::cout << std::endl << "- Nothing to do: ";  
1✔
511
                        
512
                if (p.g.network_name.empty())
1✔
NEW
513
                        std::cout << std::endl << "network name has not been specified specified, and " << std::endl << "               ";  
×
514
                std::cout << p.a.bst_file << " and " << p.a.bms_file << " do not exist." << std::endl << std::endl;  
1✔
515
                cout_mutex.unlock();
1✔
516
                return EXIT_FAILURE;
1✔
517
        }
518

519
        // output settings
520
        if (vm.count(OUTPUT_ADJ_STN_ITER))
48✔
521
                p.o._adj_stn_iteration = 1;
2✔
522
        if (vm.count(OUTPUT_ADJ_MSR_ITER))
48✔
523
                p.o._adj_msr_iteration = 1;
3✔
524
        if (vm.count(OUTPUT_CMP_MSR_ITER))
48✔
525
                p.o._cmp_msr_iteration = 1;
2✔
526
        if (vm.count(OUTPUT_ADJ_STAT_ITER))
48✔
527
                p.o._adj_stat_iteration = 1;
2✔
528
        if (vm.count(OUTPUT_ADJ_MSR) ||                                // print adjusted measurements?
60✔
529
                vm.count(OUTPUT_ADJ_GNSS_UNITS) ||                // print alternative units for adjusted GNSS measurements?
60✔
530
                vm.count(OUTPUT_ADJ_MSR_SORTBY) ||                // print sort adjusted measurements?
84✔
531
                vm.count(OUTPUT_ADJ_MSR_TSTAT))                        // print t-statistic for adjusted measurements?
48✔
532
                p.o._adj_msr_final = 1;
12✔
533

534
        if (vm.count(OUTPUT_ADJ_STN_BLOCKS))
48✔
535
                p.o._output_stn_blocks = 1;
1✔
536
        if (vm.count(OUTPUT_ADJ_MSR_BLOCKS))
48✔
537
                p.o._output_msr_blocks = 1;
1✔
538
        if (vm.count(OUTPUT_ADJ_STN_SORT_ORDER))
48✔
539
                p.o._sort_stn_file_order = 1;
2✔
540
        
541
        if (vm.count(MODE_SIMULTANEOUS))
48✔
542
                p.a.adjust_mode = SimultaneousMode;                // default
×
543
        else if (vm.count(MODE_PHASED_BLOCK1))
48✔
544
                p.a.adjust_mode = Phased_Block_1Mode;
1✔
545
#ifdef MULTI_THREAD_ADJUST
546
        else if (vm.count(MODE_PHASED_MT))
46✔
547
        {
548
                p.a.multi_thread = 1;
2✔
549
                p.a.adjust_mode = PhasedMode;
2✔
550
        }
551
#endif
552
        else if (vm.count(MODE_PHASED))
42✔
553
                p.a.adjust_mode = PhasedMode;
4✔
554
        else if (vm.count(MODE_SIMULATION))
34✔
555
                p.a.adjust_mode = SimulationMode;
×
556

557
        // Report mode?
558
        if (vm.count(MODE_ADJ_REPORT))
48✔
559
        {
560
                p.a.report_mode = true;
1✔
561
                p.a.max_iterations = 0;
1✔
562
        }
563
        else if (p.a.max_iterations < 1)
23✔
564
                p.a.report_mode = true;
×
565

566
        if (vm.count(STAGED_ADJUSTMENT))
48✔
567
        {
568
                p.a.stage = true;
5✔
569
                p.a.multi_thread = false;
5✔
570
                p.a.adjust_mode = PhasedMode;
5✔
571
                //p.o._output_stn_blocks = true;
572
        }
573

574
        // Force inverse method for measurement variances to be the same as that which
575
        // is used for the inversion of the normals
576
        //if (vm.count(LSQ_INVERSE_METHOD))
577
        //        p.a.inverse_method_msr = p.a.inverse_method_lsq;
578
        if (vm.count(SCALE_NORMAL_UNITY))
48✔
579
                p.a.scale_normals_to_unity = 1;
1✔
580
        if (vm.count(OUTPUT_ADJ_MSR_TSTAT))
48✔
581
                p.o._adj_msr_tstat = 1;
2✔
582
        if (vm.count(OUTPUT_ADJ_MSR_DBID))
48✔
583
                p.o._database_ids = 1;
1✔
584
        if (vm.count(OUTPUT_IGNORED_MSRS))
48✔
585
                p.o._print_ignored_msrs = 1;
1✔
586
        if (vm.count(PURGE_STAGE_FILES))
48✔
587
                p.a.purge_stage_files = 1;
2✔
588
        if (vm.count(RECREATE_STAGE_FILES))
48✔
589
                p.a.recreate_stage_files = 1;
3✔
590
        if (vm.count(TYPE_B_GLOBAL))
48✔
591
                p.o._apply_type_b_global = 1;
1✔
592
        if (vm.count(TYPE_B_FILE))
48✔
593
                p.o._apply_type_b_file = 1;
1✔
594

595
        p.s.asl_file = formPath<std::string>(p.g.output_folder, p.g.network_name, "asl");        // associated stations list
72✔
596
        p.s.aml_file = formPath<std::string>(p.g.output_folder, p.g.network_name, "aml");        // associated measurements list
72✔
597
        p.a.map_file = formPath<std::string>(p.g.output_folder, p.g.network_name, "map");        // station names map
72✔
598
        
599
        // has a seg file name been specified?
600
        if (vm.count(SEG_FILE))
48✔
NEW
601
                p.a.seg_file = formPath<std::string>(p.g.input_folder, p.a.seg_file);
×
602
        else
603
                p.a.seg_file = formPath<std::string>(p.g.output_folder, p.g.network_name, "seg");
72✔
604
        
605
        if (vm.count(OUTPUT_APU_CORRELATIONS))
48✔
606
                p.o._output_pu_covariances = 1;
2✔
607

608
        // Set up file names dependent on adjustment mode
609
        p.o._xyz_file = p.o._adj_file = 
24✔
610
                formPath<std::string>(p.g.output_folder, p.g.network_name);
72✔
611

612
        if (vm.count(OUTPUT_POS_UNCERTAINTY))
48✔
613
        {
614
                p.o._positional_uncertainty = 1;
6✔
615
                p.o._apu_file = p.o._adj_file;
6✔
616
        }
617

618
        if (vm.count(OUTPUT_STN_COR_FILE))
48✔
619
                p.o._cor_file = p.o._adj_file;
3✔
620

621
        switch (p.a.adjust_mode)
24✔
622
        {
623
        case Phased_Block_1Mode:
11✔
624
        case PhasedMode:
11✔
625

626
                p.o._adj_file += ".phased";
11✔
627
                p.o._xyz_file += ".phased";
11✔
628

629
                if (vm.count(OUTPUT_POS_UNCERTAINTY))
22✔
630
                        p.o._apu_file += ".phased";
3✔
631

632
                if (vm.count(OUTPUT_STN_COR_FILE))
22✔
633
                        p.o._cor_file += ".phased";
2✔
634
                
635
                if (p.a.adjust_mode == Phased_Block_1Mode)
11✔
636
                {
637
                        p.o._adj_file += "-block1";
1✔
638
                        p.o._xyz_file += "-block1";
1✔
639
                        
640
                        if (vm.count(OUTPUT_POS_UNCERTAINTY))
2✔
641
                                p.o._apu_file += "-block1";
×
642

643
                        if (vm.count(OUTPUT_STN_COR_FILE))
2✔
644
                                p.o._cor_file += "-block1";
×
645

646
                }
647
                else if (p.a.stage)
10✔
648
                {
649
                        p.o._adj_file += "-stage";
5✔
650
                        p.o._xyz_file += "-stage";
5✔
651

652
                        if (vm.count(OUTPUT_POS_UNCERTAINTY))
10✔
653
                                p.o._apu_file += "-stage";
1✔
654

655
                        if (vm.count(OUTPUT_STN_COR_FILE))
10✔
656
                                p.o._cor_file += "-stage";
1✔
657

658
                }
659
#ifdef MULTI_THREAD_ADJUST
660
                else if (p.a.multi_thread)
5✔
661
                {
662
                        p.o._adj_file += "-mt";
2✔
663
                        p.o._xyz_file += "-mt";
2✔
664
                        
665
                        if (vm.count(OUTPUT_POS_UNCERTAINTY))
4✔
666
                                p.o._apu_file += "-mt";
1✔
667

668
                        if (vm.count(OUTPUT_STN_COR_FILE))
4✔
669
                                p.o._cor_file += "-mt";
1✔
670
                }
671
#endif
672
                break;
673
        case SimultaneousMode:
13✔
674
                p.o._adj_file += ".simult";
13✔
675
                p.o._xyz_file += ".simult";
13✔
676
                
677
                if (vm.count(OUTPUT_POS_UNCERTAINTY))
26✔
678
                        p.o._apu_file += ".simult";
3✔
679
                if (vm.count(OUTPUT_STN_COR_FILE))
26✔
680
                        p.o._cor_file += ".simult";
1✔
681
                break;
682
        }
683

684
        p.o._adj_file += ".adj";
24✔
685
        p.o._xyz_file += ".xyz";
24✔
686

687
        if (vm.count(OUTPUT_POS_UNCERTAINTY))
48✔
688
                p.o._apu_file += ".apu";
6✔
689

690
        if (vm.count(OUTPUT_STN_COR_FILE))
48✔
691
                p.o._cor_file += ".cor";
3✔
692

693
        if (vm.count(OUTPUT_STN_COR_FILE))
48✔
694
                p.o._init_stn_corrections = 1;
3✔
695

696
        if (vm.count(OUTPUT_STN_CORR))
48✔
697
                p.o._stn_corr = 1;
2✔
698

699
        if (vm.count(OUTPUT_MSR_TO_STN))
48✔
700
                p.o._msr_to_stn = 1;
1✔
701
        
702
        if (vm.count(TEST_INTEGRITY))
48✔
703
                p.i.test_integrity = 1;
×
704

705
        if (vm.count(EXPORT_XML_STN_FILE))
48✔
706
                p.o._export_xml_stn_file = 1;
2✔
707

708
        if (vm.count(EXPORT_XML_MSR_FILE))
48✔
709
                p.o._export_xml_msr_file = 1;
3✔
710

711
        if (vm.count(EXPORT_DNA_STN_FILE))
48✔
712
                p.o._export_dna_stn_file = 1;
2✔
713

714
        if (vm.count(EXPORT_DNA_MSR_FILE))
48✔
715
                p.o._export_dna_msr_file = 1;
3✔
716

717
        if (vm.count(EXPORT_SNX_FILE))
48✔
718
                p.o._export_snx_file = 1;
2✔
719

720
        return EXIT_SUCCESS;
721
}
722

723
void LoadBinaryMeta(binary_file_meta_t& bst_meta, binary_file_meta_t& bms_meta,
25✔
724
        const project_settings& p, bool& bst_meta_import, bool& bms_meta_import)
725
{
726
        dna_io_bst bst;
25✔
727
        dna_io_bms bms;
25✔
728
        bst.load_bst_file_meta(p.a.bst_file, bst_meta);
25✔
729
        bms.load_bms_file_meta(p.a.bms_file, bms_meta);
25✔
730

731
        bst_meta_import = (boost::iequals(bst_meta.modifiedBy, __import_app_name__) ||
50✔
732
                boost::iequals(bst_meta.modifiedBy, __import_dll_name__));
50✔
733
        bms_meta_import = (boost::iequals(bms_meta.modifiedBy, __import_app_name__) ||
75✔
734
                boost::iequals(bms_meta.modifiedBy, __import_dll_name__));
50✔
735
}
25✔
736

737
int main(int argc, char* argv[])
41✔
738
{
739
        // create banner message
740
        std::string cmd_line_banner, stnfilename, msrfilename;        
41✔
741
        fileproc_help_header(&cmd_line_banner);
41✔
742

743
        project_settings p;
41✔
744

745
        boost::program_options::variables_map vm;
41✔
746
        boost::program_options::positional_options_description positional_options;
41✔
747

748
        boost::program_options::options_description standard_options("+ " + std::string(ALL_MODULE_STDOPT), PROGRAM_OPTIONS_LINE_LENGTH);
123✔
749
        boost::program_options::options_description adj_mode_options("+ " + std::string(ADJUST_MODULE_MODE), PROGRAM_OPTIONS_LINE_LENGTH);
123✔
750
        boost::program_options::options_description phased_adj_options("+ " + std::string(ADJUST_MODULE_PHASED), PROGRAM_OPTIONS_LINE_LENGTH);
123✔
751
        boost::program_options::options_description adj_config_options("+ " + std::string(ADJUST_MODULE_CONFIG), PROGRAM_OPTIONS_LINE_LENGTH);
123✔
752
        boost::program_options::options_description staged_adj_options("+ " + std::string(ADJUST_MODULE_STAGE), PROGRAM_OPTIONS_LINE_LENGTH);
123✔
753
        boost::program_options::options_description output_options("+ " + std::string(ALL_MODULE_OUTPUT), PROGRAM_OPTIONS_LINE_LENGTH);
123✔
754
        boost::program_options::options_description export_options("+ " + std::string(ALL_MODULE_EXPORT), PROGRAM_OPTIONS_LINE_LENGTH);
123✔
755
        boost::program_options::options_description generic_options("+ " + std::string(ALL_MODULE_GENERIC), PROGRAM_OPTIONS_LINE_LENGTH);
123✔
756

757
        std::string cmd_line_usage("+ ");
41✔
758
        cmd_line_usage.append(__BINARY_NAME__).append(" usage:  ").append(__BINARY_NAME__).append(" ").append(NETWORK_NAME).append(" [options]");
41✔
759
        boost::program_options::options_description allowable_options(cmd_line_usage, PROGRAM_OPTIONS_LINE_LENGTH);
41✔
760
        
761
        try {
41✔
762
                standard_options.add_options()
41✔
763
                        (PROJECT_FILE_P, boost::program_options::value<std::string>(&p.g.project_file),
41✔
764
                                "Project file containing all user options. If specified, all other options are ignored.")
765
                        (NETWORK_NAME_N, boost::program_options::value<std::string>(&p.g.network_name),
41✔
766
                                "Network name. User defined name for all input and output files. Default is \"network#\".")
767
                        (INPUT_FOLDER_I, boost::program_options::value<std::string>(&p.g.input_folder),
41✔
768
                                "Path containing all input files")
769
                        (OUTPUT_FOLDER_O, boost::program_options::value<std::string>(&p.g.output_folder),                // default is ./,
41✔
770
                                "Path for all output files")
771
                        (BIN_STN_FILE, boost::program_options::value<std::string>(&p.a.bst_file),
41✔
772
                                "Binary station file name. Overrides network name.")
773
                        (BIN_MSR_FILE, boost::program_options::value<std::string>(&p.a.bms_file),
41✔
774
                                "Binary measurement file name. Overrides network name.")
775
                        (SEG_FILE, boost::program_options::value<std::string>(&p.a.seg_file),
41✔
776
                                "Network segmentation file name. Overrides network name.")
777
                        (COMMENTS, boost::program_options::value<std::string>(&p.a.comments),
41✔
778
                                "Comments about the adjustment. All comments are printed to the adj file.")
779
                        ;
780

781
                adj_mode_options.add_options()
41✔
782
                        (MODE_SIMULTANEOUS,
41✔
783
                                "Simultaneous adjustment mode. The default mode.")
784
                        (MODE_PHASED,
41✔
785
                                "Sequential phased adjustment mode.")
786
                        //(MODE_SIMULATION,
787
                        //        "Adjustment simulation mode.")
788
                        (MODE_ADJ_REPORT,
41✔
789
                                "Reproduce the adjustment output files without performing an adjustment.")
790
                        ;
791

792
                phased_adj_options.add_options()
41✔
793
                        (STAGED_ADJUSTMENT,
41✔
794
                                "Store adjustment matrices in memory mapped files instead of retaining data in memory.  This option decreases efficiency but may be required if there is insufficient RAM to hold an adjustment in memory.")
795
#ifdef MULTI_THREAD_ADJUST
796
                        (MODE_PHASED_MT,
41✔
797
                                "Process forward, reverse and combination adjustments concurrently using all available CPU cores.")
798
#endif
799
                        (MODE_PHASED_BLOCK1,
41✔
800
                                "Sequential phased adjustment mode resulting in rigorous estimates for block 1 only.")
801
                        ;
802
                
803
                adj_config_options.add_options()
41✔
804
                        (CONF_INTERVAL, boost::program_options::value<float>(&p.a.confidence_interval),
41✔
805
                                (std::string("Confidence interval for testing the least squares solution and measurement corrections. Default is ")+
123✔
806
                                StringFromT(p.a.confidence_interval, 1)+std::string("%.")).c_str())
205✔
807
                        (ITERATION_THRESHOLD, boost::program_options::value<float>(&p.a.iteration_threshold),
41✔
808
                                (std::string("Least squares iteration threshold. Default is ")+
123✔
809
                                StringFromT(p.a.iteration_threshold, 4)+std::string("m.")).c_str())
205✔
810
                        (MAX_ITERATIONS, boost::program_options::value<UINT16>(&p.a.max_iterations),
41✔
811
                                (std::string("Maximum number of iterations. Default is ")+
123✔
812
                                StringFromT(p.a.max_iterations)+std::string(".")).c_str())
205✔
813
                        (STN_CONSTRAINTS, boost::program_options::value<std::string>(&p.a.station_constraints),
41✔
814
                                "Station constraints. arg is a comma delimited string \"stn1,CCC,stn2,CCF\" defining specific station constraints. These constraints override those contained in the station file.")
815
                        (FREE_STN_SD, boost::program_options::value<double>(&p.a.free_std_dev),
41✔
816
                                (std::string("A-priori standard deviation for free stations. Default is ")+
123✔
817
                                StringFromT(p.a.free_std_dev)+std::string("m.")).c_str())
205✔
818
                        (FIXED_STN_SD, boost::program_options::value<double>(&p.a.fixed_std_dev),
41✔
819
                                (std::string("A-priori standard deviation for fixed stations. Default is ")+
123✔
820
                                StringFromT(p.a.fixed_std_dev, 6)+std::string("m.")).c_str())
205✔
821
                        (SCALE_NORMAL_UNITY,
41✔
822
                                "Scale adjustment normal matrices to unity prior to computing inverse to minimise loss of precision caused by tight variances placed on constraint stations.")
823
                        (TYPE_B_GLOBAL, boost::program_options::value<std::string>(&p.a.type_b_global),
41✔
824
                                "Type b uncertainties to be added to each computed uncertainty. arg is a comma delimited string that provides 1D, 2D or 3D uncertainties in the local reference frame (e.g. \"up\" or \"e,n\" or \"e,n,up\").")
825
                        (TYPE_B_FILE, boost::program_options::value<std::string>(&p.a.type_b_file),
41✔
826
                                "Type b uncertainties file name. Full path to a file containing Type b uncertainties to be added to the computed uncertainty for specific sites.")
827
                        ;
828

829
                staged_adj_options.add_options()
41✔
830
                        (RECREATE_STAGE_FILES,
41✔
831
                                "Recreate memory mapped files.")
832
                        (PURGE_STAGE_FILES,
41✔
833
                                "Purge memory mapped files from disk upon adjustment completion.")
834
                        ;
835

836
                output_options.add_options()
41✔
837
                        (OUTPUT_MSR_TO_STN,
41✔
838
                                "Output summary of measurements connected to each station.")
839
                        (OUTPUT_MSR_TO_STN_SORTBY, boost::program_options::value<UINT16>(&p.o._sort_msr_to_stn),
41✔
840
                                std::string("Sort order for measurement to stations summary.\n  " +
164✔
841
                                        StringFromT(orig_stn_sort_ui) + ": Original station order (default)\n  " +
205✔
842
                                        StringFromT(meas_stn_sort_ui) + ": Measurement count").c_str())
41✔
843
                        (OUTPUT_ADJ_STN_ITER,
41✔
844
                                "Output adjusted station coordinates on each iteration.")
845
                        (OUTPUT_ADJ_STAT_ITER,
41✔
846
                                "Output statistical summary on each iteration.")
847
                        (OUTPUT_ADJ_MSR_ITER,
41✔
848
                                "Output adjusted measurements on each iteration.")
849
                        (OUTPUT_CMP_MSR_ITER,
41✔
850
                                "Output computed measurements on each iteration.")
851
                        (OUTPUT_ADJ_MSR,
41✔
852
                                "Output final adjusted measurements.")
853
                        (OUTPUT_ADJ_GNSS_UNITS, boost::program_options::value<UINT16>(&p.o._adj_gnss_units),
41✔
854
                                std::string("Units for adjusted GNSS baseline measurements in the .adj file.\n  " + 
164✔
855
                                        StringFromT(XYZ_adj_gnss_ui) + ": As measured (default)\n  " + 
205✔
856
                                        StringFromT(ENU_adj_gnss_ui) + ": Local [east, north, up]\n  " + 
205✔
857
                                        StringFromT(AED_adj_gnss_ui) + ": Polar [azimuth, vert. angle, slope dist]\n  " + 
205✔
858
                                        StringFromT(ADU_adj_gnss_ui) + ": Polar [azimuth, slope dist, up]").c_str())
82✔
859
                        (OUTPUT_ADJ_MSR_TSTAT,
41✔
860
                                "Output t-statistics for adjusted measurements.")
861
                        (OUTPUT_ADJ_MSR_DBID,
41✔
862
                                "Output measurement and cluster ids for database mapping.")
863
                        (OUTPUT_IGNORED_MSRS,
41✔
864
                                "Output adjusted measurement statistics for ignored measurements.")
865
                        (OUTPUT_ADJ_MSR_SORTBY, boost::program_options::value<UINT16>(&p.o._sort_adj_msr),
41✔
866
                                std::string("Sort order for adjusted measurements.\n  " + 
164✔
867
                                        StringFromT(orig_adj_msr_sort_ui) + ": Original input file order (default)\n  " + 
205✔
868
                                        StringFromT(type_adj_msr_sort_ui) + ": Measurement type\n  " + 
205✔
869
                                        StringFromT(inst_adj_msr_sort_ui) + ": Station 1\n  " + 
205✔
870
                                        StringFromT(targ_adj_msr_sort_ui) + ": Station 2\n  " + 
205✔
871
                                        StringFromT(meas_adj_msr_sort_ui) + ": Measurement value\n  " + 
205✔
872
                                        StringFromT(corr_adj_msr_sort_ui) + ": Correction\n  " + 
205✔
873
                                        StringFromT(a_sd_adj_msr_sort_ui) + ": Adjusted std. dev.\n  " + 
205✔
874
                                        StringFromT(n_st_adj_msr_sort_ui) + ": N-statistic").c_str())
82✔
875
                        (OUTPUT_ADJ_STN_BLOCKS,
41✔
876
                                "For phased adjustments, output adjusted coordinates according to each block.")
877
                        (OUTPUT_ADJ_MSR_BLOCKS,
41✔
878
                                "For phased adjustments, output adjusted measurements according to each block.")
879
                        (OUTPUT_ADJ_STN_SORT_ORDER,
41✔
880
                                "Output station information using the station order in the original station file. By default, stations are output in alpha-numeric order.")
881
                        (OUTPUT_STN_COORD_TYPES, boost::program_options::value<std::string>(&p.o._stn_coord_types),
41✔
882
                                (std::string("Output station coordinate types. arg is a case-sensitive string of chars \"ENzPLHhXYZ\" defining the specific types to be printed. Default is ").append(
82✔
883
                                p.o._stn_coord_types).append(
41✔
884
                                ".")).c_str())
885
                        (OUTPUT_ANGULAR_TYPE_STN, boost::program_options::value<UINT16>(&p.o._angular_type_stn),
41✔
886
                                std::string("Output type for angular station coordinates.\n"
82✔
887
                                        "  0: Degrees, minutes and seconds (default)\n"
888
                                        "  1: Decimal degrees").c_str())
889
                        (OUTPUT_STN_CORR,
41✔
890
                                "Output station corrections with adjusted station coordinates.")
891
                        (OUTPUT_PRECISION_METRES_STN, boost::program_options::value<UINT16>(&p.o._precision_metres_stn),
41✔
892
                                (std::string("Output precision for linear station coordinates in metres. Default is ")+
123✔
893
                                StringFromT(p.o._precision_metres_stn, 0)).c_str())
82✔
894
                        (OUTPUT_PRECISION_SECONDS_STN, boost::program_options::value<UINT16>(&p.o._precision_seconds_stn),
41✔
895
                                (std::string("Output precision for angular station coordinates. For values in degrees, minutes and seconds, precision relates to seconds. For values in decimal degrees, precision relates to degrees. Default is ")+
123✔
896
                                StringFromT(p.o._precision_seconds_stn, 0)).c_str())
82✔
897
                        (OUTPUT_PRECISION_METRES_MSR, boost::program_options::value<UINT16>(&p.o._precision_metres_msr),
41✔
898
                                (std::string("Output precision for linear measurements in metres. Default is ")+
123✔
899
                                StringFromT(p.o._precision_metres_msr, 0)).c_str())
82✔
900
                        (OUTPUT_PRECISION_SECONDS_MSR, boost::program_options::value<UINT16>(&p.o._precision_seconds_msr),
41✔
901
                                (std::string("Output precision for angular measurements. For values in degrees, minutes and seconds, precision relates to seconds. For values in decimal degrees, precision relates to degrees. Default is ")+
123✔
902
                                StringFromT(p.o._precision_seconds_msr, 0)).c_str())
82✔
903
                        (OUTPUT_ANGULAR_TYPE_MSR, boost::program_options::value<UINT16>(&p.o._angular_type_msr),
41✔
904
                                std::string("Output type for angular measurements.\n"
82✔
905
                                        "  0: Degrees, minutes and seconds (default)\n"
906
                                        "  1: Decimal degrees").c_str())
907
                        (OUTPUT_DMS_FORMAT_MSR, boost::program_options::value<UINT16>(&p.o._dms_format_msr),
41✔
908
                                std::string("Output format for angular (dms) measurements.\n"
82✔
909
                                        "  0: Separated fields (default)\n"
910
                                        "  1: Separated fields with symbols\n"
911
                                        "  2: HP notation").c_str())
912
                        ;
913

914
                export_options.add_options()
41✔
915
                        (OUTPUT_POS_UNCERTAINTY,
41✔
916
                                "Output positional uncertainty and variances of adjusted station coordinates to .apu file.")
917
                        (OUTPUT_APU_CORRELATIONS,
41✔
918
                                "Output covariances between adjusted station coordinates to .apu file.")
919
                        (OUTPUT_APU_UNITS, boost::program_options::value<UINT16>(&p.o._apu_vcv_units),
41✔
920
                                std::string("Variance matrix units in the .apu file.\n  " +
164✔
921
                                        StringFromT(XYZ_apu_ui) + ": Cartesian [X,Y,Z] (default)\n  " + 
205✔
922
                                        //StringFromT(LLH_apu_ui) + ": Geographic [Lat,Lon,ht]\n  " + 
923
                                        StringFromT(ENU_apu_ui) + ": Local [e,n,up]").c_str())
41✔
924
                        (OUTPUT_STN_COR_FILE,
41✔
925
                                "Output corrections (azimuth, distance, e, n, up) to initial station coordinates to .cor file.")
926
                        (HZ_CORR_THRESHOLD, boost::program_options::value<double>(&p.o._hz_corr_threshold),
41✔
927
                                (std::string("Minimum horizontal threshold by which to restrict output of station corrections to .cor file. Default is ")+
123✔
928
                                StringFromT(p.o._hz_corr_threshold, 1)+std::string("m")).c_str())
205✔
929
                        (VT_CORR_THRESHOLD, boost::program_options::value<double>(&p.o._vt_corr_threshold),
41✔
930
                                (std::string("Minimum vertical threshold by which to restrict output of station corrections to .cor file. Default is ")+
123✔
931
                                StringFromT(p.o._vt_corr_threshold, 1)+std::string("m")).c_str())
205✔
932
                        //(UPDATE_ORIGINAL_STN_FILE,
933
                        //        "Update original station file with adjusted station coordinates.")
934
                        (EXPORT_XML_STN_FILE,
41✔
935
                                "Export estimated station coordinates to DynaML (DynAdjust XML) station file.")
936
                        (EXPORT_XML_MSR_FILE,
41✔
937
                                "Export estimated station coordinates and uncertainties to DynaML (DynAdjust XML) measurement file as a GNSS Y cluster.")
938
                        (EXPORT_DNA_STN_FILE,
41✔
939
                                "Export estimated station coordinates to DNA station file.")
940
                        (EXPORT_DNA_MSR_FILE,
41✔
941
                                "Export estimated station coordinates and uncertainties to DNA measurement file as a GNSS Y cluster.")
942
                        (EXPORT_SNX_FILE,
41✔
943
                                "Export estimated station coordinates and full variance matrix to SINEX file. Note: station names will be truncated to four characters as per the SINEX standard.")
944
                        ;
945

946
                // Declare a group of options that will be 
947
                // allowed only on command line                
948
                generic_options.add_options()
41✔
949
                        (VERBOSE, boost::program_options::value<UINT16>(&p.g.verbose),
41✔
950
                                std::string("Give detailed information about what ").append(__BINARY_NAME__).append(" is doing.\n"
82✔
951
                                        "  0: No information (default)\n"
952
                                        "  1: Helpful information\n"
953
                                        "  2: Extended information\n"
954
                                        "  3: Debug level information").c_str())
955
                        (QUIET,
41✔
956
                                std::string("Suppresses all explanation of what ").append(__BINARY_NAME__).append(" is doing unless an error occurs").c_str())
82✔
957
                        (VERSION_V, "Display the current program version")
41✔
958
                        (HELP_H, "Show this help message")
41✔
959
                        (HELP_MODULE_H, boost::program_options::value<std::string>(),
41✔
960
                                "Provide help for a specific help category.")
961
                        ;
962

963
                allowable_options.add(standard_options).add(adj_mode_options).add(phased_adj_options).add(adj_config_options).add(staged_adj_options).add(output_options).add(export_options).add(generic_options);
41✔
964

965
                // add "positional options" to handle command line tokens which have no option name
966
                positional_options.add(NETWORK_NAME, -1);
41✔
967
                
968
                boost::program_options::command_line_parser parser(argc, argv);
41✔
969
                store(parser.options(allowable_options).positional(positional_options).run(), vm);
41✔
970
                notify(vm);
40✔
971
        } 
1✔
972
        catch (const std::exception& e) {
1✔
973
                cout_mutex.lock();
1✔
974
                std::cout << "- Error: " << e.what() << std::endl;
1✔
975
                std::cout << cmd_line_banner << allowable_options << std::endl;
1✔
976
                cout_mutex.unlock();
1✔
977
                return EXIT_FAILURE;
1✔
978
        }
1✔
979
        catch (...) 
×
980
        {
NEW
981
                std::cout << "+ Exception of unknown type!\n";
×
982
                return EXIT_FAILURE;
×
983
        }
×
984

985
        if (argc < 2)
40✔
986
        {
987
                std::cout << std::endl << "- Nothing to do - no options provided. " << std::endl << std::endl;  
1✔
988
                std::cout << cmd_line_banner << allowable_options << std::endl;
1✔
989
                return EXIT_FAILURE;
990
        }
991

992
        if (vm.count(VERSION))
78✔
993
        {
994
                std::cout << cmd_line_banner << std::endl;
1✔
995
                return EXIT_SUCCESS;
996
        }
997

998
        if (vm.count(HELP))
76✔
999
        {
1000
                std::cout << cmd_line_banner << allowable_options << std::endl;
1✔
1001
                return EXIT_SUCCESS;
1002
        }
1003

1004
        if (vm.count(HELP_MODULE)) 
74✔
1005
        {
1006
                std::cout << cmd_line_banner;
9✔
1007
                std::string original_text = vm[HELP_MODULE].as<std::string>();
27✔
1008
                std::string help_text = str_upper<std::string>(original_text);
9✔
1009
                bool module_found(false);
9✔
1010

1011
                if (str_upper<std::string, char>(ALL_MODULE_STDOPT).find(help_text) != std::string::npos) {
27✔
1012
                        std::cout << standard_options << std::endl;
1✔
1013
                        module_found = true;
1014
                }
1015

1016
                if (str_upper<std::string, char>(ADJUST_MODULE_MODE).find(help_text) != std::string::npos) {
27✔
1017
                        std::cout << adj_mode_options << std::endl;
1✔
1018
                        module_found = true;
1019
                } 
1020

1021
                if (str_upper<std::string, char>(ADJUST_MODULE_PHASED).find(help_text) != std::string::npos) {
27✔
1022
                        std::cout << phased_adj_options << std::endl;
2✔
1023
                        module_found = true;
1024
                } 
1025

1026
                if (str_upper<std::string, char>(ADJUST_MODULE_CONFIG).find(help_text) != std::string::npos) {
27✔
1027
                        std::cout << adj_config_options << std::endl;
1✔
1028
                        module_found = true;
1029
                } 
1030

1031
                if (str_upper<std::string, char>(ADJUST_MODULE_STAGE).find(help_text) != std::string::npos) {
27✔
1032
                        std::cout << staged_adj_options << std::endl;
2✔
1033
                        module_found = true;
1034
                } 
1035

1036
                if (str_upper<std::string, char>(ALL_MODULE_OUTPUT).find(help_text) != std::string::npos) {
27✔
1037
                        std::cout << output_options << std::endl;
1✔
1038
                        module_found = true;
1039
                } 
1040

1041
                if (str_upper<std::string, char>(ALL_MODULE_EXPORT).find(help_text) != std::string::npos) {
27✔
1042
                        std::cout << export_options << std::endl;
1✔
1043
                        module_found = true;
1044
                }
1045

1046
                if (str_upper<std::string, char>(ALL_MODULE_GENERIC).find(help_text) != std::string::npos) {
27✔
1047
                        std::cout << generic_options << std::endl;
1✔
1048
                        module_found = true;
1049
                }
1050

1051
                if (!module_found) {
8✔
1052
                        std::cout << std::endl << "- Error: Help module '" <<
1✔
1053
                                original_text << "' is not in the list of options." << std::endl;
9✔
1054
                        return EXIT_FAILURE;
1055
                }
1056

1057
                return EXIT_SUCCESS;
8✔
1058
        }
18✔
1059

1060
        bool userSuppliedSegFile(false);
28✔
1061
        if (!p.a.seg_file.empty())
28✔
1062
                userSuppliedSegFile = true;
×
1063
        bool userSuppliedBstFile(false);
28✔
1064
        if (!p.a.bst_file.empty())
28✔
1065
                userSuppliedBstFile = true;
×
1066
        bool userSuppliedBmsFile(false);
28✔
1067
        if (!p.a.bms_file.empty())
28✔
1068
                userSuppliedBmsFile = true;
×
1069

1070
        if (ParseCommandLineOptions(argc, argv, vm, p) != EXIT_SUCCESS)
28✔
1071
                return EXIT_FAILURE;
1072

1073
        // Create an instance of the dna_adjust object exposed by the dnaadjust dll
1074
        dna_adjust netAdjust;
25✔
1075

1076
        // Capture binary file metadata
1077
        binary_file_meta_t bst_meta, bms_meta;
25✔
1078
        bool bst_meta_import, bms_meta_import;
25✔
1079
        LoadBinaryMeta(bst_meta, bms_meta, p, bst_meta_import, bms_meta_import);
25✔
1080

1081
        // Capture datum set within project file
1082
        CDnaDatum datum;
25✔
1083
        
1084
        // Inspect if reftran has been executed.  If so, select the appropriate 
1085
        // reference frame label
1086
        if (bst_meta.reftran)
25✔
1087
                datum.SetDatumFromName(p.r.reference_frame, p.r.epoch);
3✔
1088
        else
1089
                datum.SetDatumFromName(p.i.reference_frame, p.i.epoch);
22✔
1090

1091
        if (vm.count(QUIET))
50✔
1092
                p.g.quiet = 1;
×
1093
        
1094
        if (!p.g.quiet)
25✔
1095
        {
1096
                cout_mutex.lock();
25✔
1097
                std::cout << std::endl << cmd_line_banner;
25✔
1098

1099
                std::cout << "+ Options:" << std::endl;
25✔
1100
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Network name: " <<  p.g.network_name << std::endl;
25✔
1101
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Input folder: " << p.g.input_folder << std::endl;
25✔
1102
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Output folder: " << p.g.output_folder << std::endl;
25✔
1103
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Associated station file: " << p.s.asl_file << std::endl;
25✔
1104
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Associated measurement file: " << p.s.aml_file << std::endl;
25✔
1105
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Binary station file: " << p.a.bst_file << std::endl;
25✔
1106
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Binary measurement file: " << p.a.bms_file << std::endl;
25✔
1107
                if (p.a.adjust_mode == PhasedMode || p.a.adjust_mode == Phased_Block_1Mode)
25✔
1108
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Segmentation file: " << p.a.seg_file << std::endl;
11✔
1109
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Adjustment output file: " << p.o._adj_file << std::endl;
25✔
1110
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Coordinate output file: " << p.o._xyz_file << std::endl;
25✔
1111
                if (p.o._init_stn_corrections)
25✔
1112
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Corrections output file: " << p.o._cor_file << std::endl;
3✔
1113
                
1114
                if (p.a.stage)
25✔
1115
                {
1116
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Stage using hard disk: " << "yes" << std::endl;
5✔
1117
                        if (p.a.recreate_stage_files)
5✔
1118
                                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Recreate mapped stage files: " << "yes" << std::endl;
3✔
1119
                        if (p.a.purge_stage_files)
5✔
1120
                                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Purge mapped stage files: " << "yes" << std::endl;
2✔
1121
                }                
1122
                
1123
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Reference frame: " << datum.GetName() << std::endl;
25✔
1124
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Epoch: " << datum.GetEpoch_s() << std::endl;
50✔
1125
                
1126
                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Geoid model: " << boost::filesystem::system_complete(p.n.ntv2_geoid_file).string() << std::endl;
50✔
1127

1128
                if (p.a.scale_normals_to_unity)
25✔
1129
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Scale normals to unity: " << "yes" << std::endl;
1✔
1130
                if (!p.a.station_constraints.empty())
25✔
1131
                {
1132
                        std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Station constraints: " << p.a.station_constraints << std::endl;
4✔
1133
                        if (p.i.apply_discontinuities)
4✔
1134
                                std::cout << std::setw(PRINT_VAR_PAD) << std::left << "  Apply discontinuities: " << "yes" << std::endl;
1✔
1135
                }
1136

1137
                switch (p.a.adjust_mode)
25✔
1138
                {
1139
                case Phased_Block_1Mode:
11✔
1140
                case PhasedMode:
11✔
1141

1142
                        if (!boost::filesystem::exists(p.a.seg_file))
22✔
1143
                        {
1144
                                std::cout << std::endl << std::endl << 
1✔
1145
                                        "- Error: The required segmentation file does not exist:" << std::endl;  
1✔
1146
                                std::cout << "         " << p.a.seg_file << std::endl << std::endl;
1✔
1147
                                std::cout << "  Run  'segment " << p.g.network_name << "' to create a segmentation file" << std::endl << std::endl;
1✔
1148
                                cout_mutex.unlock();
1✔
1149
                                return EXIT_FAILURE;
1✔
1150
                        }
1151

1152
                        // Load the segmentation file parameters into the dll, mainly
1153
                        // the segmentation block count, which is used by the progress 
1154
                        // thread before the adjustment begins
1155
                        netAdjust.LoadSegmentationFileParameters(p.a.seg_file);
10✔
1156
                }
1157
        
1158
                std::cout << std::endl;
24✔
1159
                std::cout << std::setw(PRINT_VAR_PAD) << std::left;
24✔
1160
                switch (p.a.adjust_mode)
24✔
1161
                {
1162
                case SimultaneousMode:
14✔
1163
                        std::cout << "+ Simultaneous adjustment mode" << std::endl;
14✔
1164
                        break;
1165
                case PhasedMode:
9✔
1166
                        std::cout << "+ Rigorous sequential phased adjustment mode";
9✔
1167
                        if (p.a.stage)
9✔
1168
                                std::cout << " (staged)";
5✔
1169

1170
                        // If the user has not provided a seg file, check the meta of the default file
1171
                        if (!userSuppliedSegFile)
9✔
1172
                        {
1173
                                if (boost::filesystem::last_write_time(p.a.seg_file) < boost::filesystem::last_write_time(p.a.bst_file) ||
27✔
1174
                                        boost::filesystem::last_write_time(p.a.seg_file) < boost::filesystem::last_write_time(p.a.bms_file))
25✔
1175
                                {
1176
                                        // Has import been run after the segmentation file was created?
1177
                                        if ((bst_meta_import && (boost::filesystem::last_write_time(p.a.seg_file) < boost::filesystem::last_write_time(p.a.bst_file))) || 
2✔
1178
                                                (bms_meta_import && (boost::filesystem::last_write_time(p.a.seg_file) < boost::filesystem::last_write_time(p.a.bms_file))))
1✔
1179
                                        {
NEW
1180
                                                std::cout << std::endl << std::endl << 
×
NEW
1181
                                                        "- Error: The raw stations and measurements have been imported after" << std::endl <<
×
NEW
1182
                                                        "  the segmentation file was created:" << std::endl;
×
1183

NEW
1184
                                                time_t t_bst(boost::filesystem::last_write_time(p.a.bst_file)), t_bms(boost::filesystem::last_write_time(p.a.bms_file));
×
NEW
1185
                                                time_t t_seg(boost::filesystem::last_write_time(p.a.seg_file));
×
1186

NEW
1187
                                                std::cout << "   " << leafStr<std::string>(p.a.bst_file) << "  last modified on  " << ctime(&t_bst);
×
NEW
1188
                                                std::cout << "   " << leafStr<std::string>(p.a.bms_file) << "  last modified on  " << ctime(&t_bms) << std::endl;
×
NEW
1189
                                                std::cout << "   " << leafStr<std::string>(p.a.seg_file) << "  created on  " << ctime(&t_seg) << std::endl;
×
NEW
1190
                                                std::cout << "  Run 'segment " << p.g.network_name << " [options]' to re-create the segmentation file, or re-run" << std::endl << 
×
1191
                                                        "  adjust using the --" << SEG_FILE << " option if the file " << 
NEW
1192
                                                        boost::filesystem::path(p.a.seg_file).stem() << " must\n  be used." << std::endl << std::endl;
×
1193
                                                cout_mutex.unlock();
×
1194
                                                return EXIT_FAILURE;
×
1195
                                        }
1196
                                }
1197
                        }
1198

1199
                        // Has import been run after a staged adjustment was run, and this adjustment intends
1200
                        // to reuse memory mapped files created in the previous staged adjustment?
1201
                        if (p.a.stage && !p.a.recreate_stage_files)
9✔
1202
                        {
1203
                                // Simply test one file - the estimated stations file
1204
                                std::string est_mmapfile_name =
2✔
1205
                                        p.g.output_folder + FOLDER_SLASH + 
4✔
1206
                                        p.g.network_name + "-est.mtx";
2✔
1207
                                std::string est_mmapfile_wildcard =
2✔
1208
                                        p.g.output_folder + FOLDER_SLASH + 
4✔
1209
                                        p.g.network_name + "-*.mtx";
2✔
1210
                                if (boost::filesystem::exists(est_mmapfile_name))
4✔
1211
                                {
1212
                                        // Has import been run after the segmentation file was created?
1213
                                        
1214
                                        // This warning is here for the following reasons:
1215
                                        //  1. import recreates the binary station and measurement files.  At this time, the reduced flag in the
1216
                                        //     metadata record is set to false.
1217
                                        //        2. When adjust is run for the first time, adjust reduces raw measurements to the ellipsoid (i.e. 
1218
                                        //     applies n-values and deflections), applies scaling to GPS variance matrices, and then updates the 
1219
                                        //     binary measurement file. adjust then sets the reduced flag in the metadata record to true.
1220
                                        //  3. If a user decides to re-run import and segment, then attempts to run 
1221
                                        //     'adjust network-name --stage' (i.e. without recreating the stage files) after import or segment, 
1222
                                        //     then adjust will attempt to load memory map files using the same parameters from the first import
1223
                                        //     and segment.
1224
                                        //  Hence, force the user to run adjust with the --create-stage-files option.
1225
                                        if ((bst_meta_import && (boost::filesystem::last_write_time(est_mmapfile_name) < boost::filesystem::last_write_time(p.a.bst_file))) ||
2✔
1226
                                                (bms_meta_import && (boost::filesystem::last_write_time(est_mmapfile_name) < boost::filesystem::last_write_time(p.a.bms_file))))
1✔
1227
                                        {
NEW
1228
                                                std::cout << std::endl << std::endl << 
×
NEW
1229
                                                        "- Error: The raw stations and measurements have been imported after" << std::endl <<
×
NEW
1230
                                                        "  a staged adjustment created the memory map files:" << std::endl;
×
1231
                                                
NEW
1232
                                                time_t t_bst(boost::filesystem::last_write_time(p.a.bst_file)), t_bms(boost::filesystem::last_write_time(p.a.bms_file));
×
NEW
1233
                                                time_t t_mtx(boost::filesystem::last_write_time(est_mmapfile_name));
×
1234

NEW
1235
                                                std::cout << "   " << leafStr<std::string>(p.a.bst_file) << "  last modified on  " << ctime(&t_bst);
×
NEW
1236
                                                std::cout << "   " << leafStr<std::string>(p.a.bms_file) << "  last modified on  " << ctime(&t_bms) << std::endl;
×
NEW
1237
                                                std::cout << "   " << leafStr<std::string>(est_mmapfile_wildcard) << "  created on  " << ctime(&t_mtx) << std::endl;
×
NEW
1238
                                                std::cout << "  To readjust this network, re-run adjust using the " << RECREATE_STAGE_FILES << " option." << std::endl;
×
1239
                                                cout_mutex.unlock();
×
1240
                                                return EXIT_FAILURE;
×
1241
                                        }                                
1242
                                }
1243
                        }
4✔
1244
                        
1245
#ifdef MULTI_THREAD_ADJUST
1246
                        if (p.a.multi_thread)
9✔
1247
                        {
1248
                                std::cout << std::endl << "+ Optimised for concurrent processing via multi-threading." << std::endl << std::endl;
2✔
1249
                                std::cout << "+ The active CPU supports the execution of " << boost::thread::hardware_concurrency() << " concurrent threads.";
2✔
1250
                        }
1251
#endif
1252
                        std::cout << std::endl;
9✔
1253
                        break;
1254
                case Phased_Block_1Mode:
1✔
1255
                        std::cout << "+ Sequential phased adjustment resulting in rigorous estimates for Block 1 only" << std::endl;
1✔
1256
                        
1257
                        break;
1258
                case SimulationMode:
×
NEW
1259
                        std::cout << "+ Adjustment simulation only" << std::endl;
×
1260
                        break;
1261
                }
1262
                std::cout << std::endl;
24✔
1263
                
1264
                if (p.a.report_mode)
24✔
1265
                {
1266
                        std::cout << "+ Report last adjustment results" << std::endl;
1✔
1267

1268
                        // Has report mode been requested as well as an argument to recreate stage files?
1269
                        // If so, return an error message and exit as this will lead to reporting of 
1270
                        // incorrect (zero!) results
1271
                        if (p.a.recreate_stage_files)
1✔
1272
                        {
NEW
1273
                                std::cout << std::endl <<
×
NEW
1274
                                        "- Error: The option --" << RECREATE_STAGE_FILES << " cannot be used in Report results mode" << std::endl <<
×
NEW
1275
                                        "  as it will erase the results from the latest adjustment and create new stage" << std::endl <<
×
NEW
1276
                                        "  files initialised to zero." << std::endl << std::endl;
×
NEW
1277
                                cout_mutex.unlock();
×
NEW
1278
                                return EXIT_FAILURE;
×
1279
                        }
1280
                }
1281
                
1282
                cout_mutex.unlock();
24✔
1283
        }
1284
        
1285
        boost::posix_time::milliseconds elapsed_time(boost::posix_time::milliseconds(0));
24✔
1286
        
1287
        _ADJUST_STATUS_ adjustStatus;
24✔
1288
        
1289
        try {
24✔
1290
                running = true;
24✔
1291
                
1292
                // adjust blocks using group thread
1293
                boost::thread_group ui_adjust_threads;
24✔
1294
                if (!p.g.quiet)
24✔
1295
                        ui_adjust_threads.create_thread(dna_adjust_progress_thread(&netAdjust, &p));
24✔
1296
                ui_adjust_threads.create_thread(dna_adjust_thread(&netAdjust, &p, &adjustStatus));
24✔
1297
                ui_adjust_threads.join_all();
24✔
1298

1299
                switch (adjustStatus)
24✔
1300
                {
1301
                case ADJUST_EXCEPTION_RAISED:
4✔
1302
                        running = false;
4✔
1303
                        return EXIT_FAILURE;
4✔
1304
                default:
20✔
1305
                        break;
20✔
1306
                }
1307

1308
                if (p.a.report_mode)
20✔
1309
                        // Load variance matrices into memory
1310
                        DeserialiseVarianceMatrices(&netAdjust, &p);
1✔
1311

1312
                elapsed_time = netAdjust.adjustTime();
20✔
1313

1314
                // Print summary message
1315
                PrintSummaryMessage(&netAdjust, &p, &elapsed_time);
20✔
1316

1317
                if (netAdjust.GetStatus() > ADJUST_THRESHOLD_EXCEEDED)
20✔
1318
                        return ADJUST_SUCCESS;
1319

1320
                // Generate statistics
1321
                GenerateStatistics(&netAdjust, &p);
20✔
1322

1323
                if (p.a.max_iterations > 0)
20✔
1324
                        // Write variance matrices to disk
1325
                        SerialiseVarianceMatrices(&netAdjust, &p);
19✔
1326

1327
                // Print adjusted measurements to ADJ file
1328
                PrintAdjustedMeasurements(&netAdjust, &p);
20✔
1329

1330
                // Print measurements to stations table
1331
                PrintMeasurementstoStations(&netAdjust, &p);
20✔
1332

1333
                // Print adjusted stations to adj and xyz files
1334
                PrintAdjustedNetworkStations(&netAdjust, &p);
20✔
1335

1336
                // close adj and xyz files
1337
                netAdjust.CloseOutputFiles();
20✔
1338

1339
                // Print positional uncertainty
1340
                PrintPositionalUncertainty(&netAdjust, &p);
20✔
1341

1342
                // Print station coordinates
1343
                PrintStationCorrections(&netAdjust, &p);
20✔
1344

1345
                // Update bst and bms files with adjustment results
1346
                UpdateBinaryFiles(&netAdjust, &p);
20✔
1347

1348
                // Print adjusted stations and measurements to DynaML
1349
                ExportDynaML(&netAdjust, &p);
20✔
1350

1351
                // Print adjusted stations and measurements to DNA stn and msr
1352
                ExportDNA(&netAdjust, &p);
20✔
1353

1354
                // Print adjusted stations and measurements to SINEX
1355
                ExportSinex(&netAdjust, &p);
20✔
1356
        }
24✔
1357
        catch (const NetAdjustException& e) {
×
1358
                cout_mutex.lock();
×
NEW
1359
                std::cout << std::endl << 
×
NEW
1360
                        "- Error: " << e.what() << std::endl;
×
1361
                cout_mutex.unlock();
×
1362
                return EXIT_FAILURE;
×
1363
        }
×
1364

1365
        if (!p.g.quiet)
20✔
1366
                std::cout << std::endl << "+ Open " << leafStr<std::string>(p.o._adj_file) << " to view the adjustment details." << std::endl << std::endl;
60✔
1367
        
1368
        if (!userSuppliedSegFile)
20✔
1369
                p.a.seg_file = "";
20✔
1370
        if (!userSuppliedBstFile)
20✔
1371
                p.a.bst_file = "";
20✔
1372
        if (!userSuppliedBmsFile)
20✔
1373
                p.a.bms_file = "";
20✔
1374

1375
        // Look for a project file.  If it exists, open and load it.
1376
        // Update the import settings.
1377
        // Print the project file. If it doesn't exist, it will be created.
1378
        CDnaProjectFile projectFile;
40✔
1379
        if (boost::filesystem::exists(p.g.project_file))
40✔
1380
                projectFile.LoadProjectFile(p.g.project_file);
20✔
1381
        
1382
        projectFile.UpdateSettingsAdjust(p);
20✔
1383
        projectFile.UpdateSettingsOutput(p);
20✔
1384
        projectFile.PrintProjectFile();        
20✔
1385

1386
        return ADJUST_SUCCESS;
20✔
1387
}
255✔
1388

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc