File: gnssStationInfoCreate.cpp

package info (click to toggle)
groops 0%2Bgit20240830%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 11,052 kB
  • sloc: cpp: 134,939; fortran: 1,569; makefile: 20
file content (205 lines) | stat: -rw-r--r-- 9,052 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/***********************************************/
/**
* @file gnssStationInfoCreate.cpp
*
* @brief create station information file for GNSS receivers.
*
* @author Torsten Mayer-Guerr
* @date 2012-11-24
*/
/***********************************************/

// Latex documentation
#define DOCSTRING docstring
static const char *docstring = R"(
Create a \file{GnssStationInfo file}{gnssStationInfo} from scratch by defining attributes such as
\config{markerName}, \config{markerNumber}, \config{comment}, \config{approxPosition},
\config{antenna} and \config{receiver}.

See also \program{GnssAntex2AntennaDefinition} and \program{GnssStationLog2Platform}.
)";

/***********************************************/

#include "programs/program.h"
#include "files/fileGnssStationInfo.h"

/***** CLASS ***********************************/

/** @brief create station information file for GNSS receivers.
* @ingroup programsGroup */
class GnssStationInfoCreate
{
public:
  void run(Config &config, Parallel::CommunicatorPtr comm);
};

GROOPS_REGISTER_PROGRAM(GnssStationInfoCreate, SINGLEPROCESS, "create station information file for GNSS receivers", Gnss)
GROOPS_RENAMED_PROGRAM(GnssCreateStationInfo, GnssStationInfoCreate, date2time(2019, 9, 5))

/***********************************************/

static Bool readConfig(Config &config, const std::string &name, GnssAntennaInfo &var, Config::Appearance mustSet, const std::string &defaultValue, const std::string &annotation)
{
  try
  {
    if(!readConfigSequence(config, name, mustSet, defaultValue, annotation))
      return FALSE;

    Angle angleX, angleY, angleZ;
    Bool  flipx, flipy, flipz;

    readConfig(config, "name",        var.name,         Config::MUSTSET,  "",  "");
    readConfig(config, "serial",      var.serial,       Config::OPTIONAL, "",  "");
    readConfig(config, "radome",      var.radome,       Config::OPTIONAL, "",  "");
    readConfig(config, "comment",     var.comment,      Config::OPTIONAL, "",  "");
    readConfig(config, "timeStart",   var.timeStart,    Config::OPTIONAL, "",  "");
    readConfig(config, "timeEnd",     var.timeEnd,      Config::OPTIONAL, "",  "");
    readConfig(config, "positionX",   var.position.x(), Config::MUSTSET,  "0", "[m] ARP in north, east, up or vehicle system");
    readConfig(config, "positionY",   var.position.y(), Config::MUSTSET,  "0", "[m] ARP in north, east, up or vehicle system");
    readConfig(config, "positionZ",   var.position.z(), Config::MUSTSET,  "0", "[m] ARP in north, east, up or vehicle system");
    readConfig(config, "rotationX",   angleX,           Config::DEFAULT,  "0", "[degree] from local/vehicle to left-handed antenna system");
    readConfig(config, "rotationY",   angleY,           Config::DEFAULT,  "0", "[degree] from local/vehicle to left-handed antenna system");
    readConfig(config, "rotationZ",   angleZ,           Config::DEFAULT,  "0", "[degree] from local/vehicle to left-handed antenna system");
    readConfig(config, "flipX",       flipx,            Config::DEFAULT,  "0", "flip x-axis (after rotation)");
    readConfig(config, "flipY",       flipy,            Config::DEFAULT,  "0", "flip y-axis (after rotation)");
    readConfig(config, "flipZ",       flipz,            Config::DEFAULT,  "0", "flip z-axis (after rotation)");
    endSequence(config);
    if(isCreateSchema(config))
      return TRUE;

    if(var.timeEnd == Time())
      var.timeEnd = date2time(2500,1,1);
    var.local2antennaFrame = rotaryZ(angleZ) * rotaryY(angleY) * rotaryX(angleX);
    if(flipx) var.local2antennaFrame = flipX() * var.local2antennaFrame;
    if(flipy) var.local2antennaFrame = flipY() * var.local2antennaFrame;
    if(flipz) var.local2antennaFrame = flipZ() * var.local2antennaFrame;

    return TRUE;
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

/***********************************************/

static Bool readConfig(Config &config, const std::string &name, GnssReceiverInfo &var, Config::Appearance mustSet, const std::string &defaultValue, const std::string &annotation)
{
  try
  {
    if(!readConfigSequence(config, name, mustSet, defaultValue, annotation))
      return FALSE;

    readConfig(config, "name",      var.name,      Config::MUSTSET,  "",  "");
    readConfig(config, "serial",    var.serial,    Config::OPTIONAL, "",  "");
    readConfig(config, "version",   var.version,   Config::OPTIONAL, "",  "");
    readConfig(config, "comment",   var.comment,   Config::OPTIONAL, "",  "");
    readConfig(config, "timeStart", var.timeStart, Config::OPTIONAL, "",  "");
    readConfig(config, "timeEnd",   var.timeEnd,   Config::OPTIONAL, "",  "");
    endSequence(config);
    return TRUE;
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

/***********************************************/

static Bool readConfig(Config &config, const std::string &name, GnssReferencePointInfo &var, Config::Appearance mustSet, const std::string &defaultValue, const std::string &annotation)
{
  try
  {
    if(!readConfigSequence(config, name, mustSet, defaultValue, annotation))
      return FALSE;

    readConfig(config, "comment",   var.comment,        Config::OPTIONAL, "",  "");
    readConfig(config, "xStart",    var.pointStart.x(), Config::MUSTSET,  "0", "[m] in north, east, up or vehicle system");
    readConfig(config, "yStart",    var.pointStart.y(), Config::MUSTSET,  "0", "linear motion between start and end");
    readConfig(config, "zStart",    var.pointStart.z(), Config::MUSTSET,  "0", "");
    readConfig(config, "xEnd",      var.pointEnd.x(),   Config::MUSTSET,  "0", "[m] in north, east, up or vehicle system");
    readConfig(config, "yEnd",      var.pointEnd.y(),   Config::MUSTSET,  "0", "linear motion between start and end");
    readConfig(config, "zEnd",      var.pointEnd.z(),   Config::MUSTSET,  "0", "");
    readConfig(config, "timeStart", var.timeStart,      Config::OPTIONAL, "",  "");
    readConfig(config, "timeEnd",   var.timeEnd,        Config::OPTIONAL, "",  "");
    endSequence(config);
    return TRUE;
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

/***********************************************/

void GnssStationInfoCreate::run(Config &config, Parallel::CommunicatorPtr /*comm*/)
{
  try
  {
    FileName        outFileName;
    GnssStationInfo station;

    readConfig(config, "outputfileStationInfo", outFileName,                Config::MUSTSET,  "",  "");
    readConfig(config, "markerName",            station.markerName,         Config::MUSTSET,  "",  "");
    readConfig(config, "markerNumber",          station.markerNumber,       Config::OPTIONAL, "",  "");
    readConfig(config, "comment",               station.comment,            Config::OPTIONAL, "",  "");
    readConfig(config, "approxPositionX",       station.approxPosition.x(), Config::DEFAULT,  "0", "[m] in TRF");
    readConfig(config, "approxPositionY",       station.approxPosition.y(), Config::DEFAULT,  "0", "[m] in TRF");
    readConfig(config, "approxPositionZ",       station.approxPosition.z(), Config::DEFAULT,  "0", "[m] in TRF");
    readConfig(config, "antenna",               station.antenna,            Config::MUSTSET,  "",  "");
    readConfig(config, "receiver",              station.receiver,           Config::OPTIONAL, "",  "");
    readConfig(config, "referencePoint",        station.referencePoints,    Config::OPTIONAL, "",  "e.g. center of mass in satellite frame");
    if(isCreateSchema(config)) return;

    // ============================

    // check antennas
    // --------------
    if(station.antenna.size())
    {
      for(UInt i=0; i<station.antenna.size()-1; i++)
        if(station.antenna.at(i).timeEnd == Time())
          station.antenna.at(i).timeEnd = station.antenna.at(i+1).timeStart;
      if(station.antenna.back().timeEnd == Time())
        station.antenna.back().timeEnd = date2time(2500,1,1);
    }

    // check receivers
    // ----------------
    if(station.receiver.size())
    {
      for(UInt i=0; i<station.receiver.size()-1; i++)
        if(station.receiver.at(i).timeEnd == Time())
          station.receiver.at(i).timeEnd = station.receiver.at(i+1).timeStart;
      if(station.receiver.back().timeEnd == Time())
        station.receiver.back().timeEnd = date2time(2500,1,1);
    }

    // check reference points
    // ----------------------
    if(station.referencePoints.size())
    {
      for(UInt i=0; i<station.referencePoints.size()-1; i++)
        if(station.referencePoints.at(i).timeEnd == Time())
          station.referencePoints.at(i).timeEnd = station.referencePoints.at(i+1).timeStart;
      if(station.referencePoints.back().timeEnd == Time())
        station.referencePoints.back().timeEnd = date2time(2500,1,1);
    }

    // ============================

    logStatus<<"write antenna definition <"<<outFileName<<">"<<Log::endl;
    writeFileGnssStationInfo(outFileName, station);
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

/***********************************************/
/***********************************************/