forked from ngageoint/csm
-
Notifications
You must be signed in to change notification settings - Fork 13
/
csm.h
470 lines (422 loc) · 15.7 KB
/
csm.h
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
//#############################################################################
//
// FILENAME: csm.h
//
// CLASSIFICATION: Unclassified
//
// DESCRIPTION:
//
// Header for constants and other definitions used in the CSM API.
//
// LIMITATIONS: None
//
//
// SOFTWARE HISTORY:
// Date Author Comment
// ----------- ------ -------
// 01-Jul-2003 LMT Initial version.
// 02-Mar-2012 SCM Added csm namespace.
// 30-Oct-2012 SCM Changed covariances from std::vectors to arrays.
// Made the covariances public.
// 30-Oct-2012 SCM Renamed to csm.h
// 31-Oct-2012 SCM Moved common sensor type and mode defines here.
// 29-Nov-2012 JPK Added Parameter and SharingCriteria structs and
// ParamSet struct.
// 06-Dec-2012 JPK Renamed ParamSet and ParamType to Set and Type
// and put them in new namespace "param".
// Implemented additional constructors for
// ImageCoordCovar and EcefCoordCovar and added
// new struct EcefLocus.
// 17-Dec-2012 BAH Documentation updates.
// 12-Feb-2013 JPK Renamed param::EXACT to param::FIXED
// 10-Sep-2013 SCM Added std namespace to memory function calls.
// 22-Feb-2018 JPK Updated version to 3.0.3
//
// NOTES:
//
//#############################################################################
#ifndef __CSM_CSM_H
#define __CSM_CSM_H
#include <vector>
#include <string>
#include <cstring>
#ifdef _WIN32
# ifdef CSM_LIBRARY
# define CSM_EXPORT_API __declspec(dllexport)
# else
# define CSM_EXPORT_API __declspec(dllimport)
# endif
#elif LINUX_BUILD
# define CSM_EXPORT_API __attribute__ ((visibility("default")))
#else
# define CSM_EXPORT_API
#endif
// The getCsmVersion method should use CURRENT_CSM_VERSION to
// return the CSM API version that the sensor model/plugin was written to.
#define CURRENT_CSM_VERSION csm::Version(3, 0, 3);
// Common definition for an unknown name, type, node,etc.
#define CSM_UNKNOWN "UNKNOWN"
// Common sensor types returned from the csm::Model::getSensorType method.
#define CSM_SENSOR_TYPE_UNKNOWN CSM_UNKNOWN
#define CSM_SENSOR_TYPE_EO "EO"
#define CSM_SENSOR_TYPE_IR "IR"
#define CSM_SENSOR_TYPE_MWIR "MWIR"
#define CSM_SENSOR_TYPE_LWIR "LWIR"
#define CSM_SENSOR_TYPE_SAR "SAR"
#define CSM_SENSOR_TYPE_EOIRSC "EO_IR_SPECIAL_CASE"
// Common sensor modes returned from the csm::Model::getSensorMode method.
#define CSM_SENSOR_MODE_UNKNOWN CSM_UNKNOWN
#define CSM_SENSOR_MODE_FRAME "FRAME"
#define CSM_SENSOR_MODE_PULSE "PULSE"
#define CSM_SENSOR_MODE_PB "PUSHBROOM"
#define CSM_SENSOR_MODE_WB "WHISKBROOM"
#define CSM_SENSOR_MODE_SPOT "SPOT"
#define CSM_SENSOR_MODE_STRIP "STRIP"
#define CSM_SENSOR_MODE_SCAN "SCAN"
#define CSM_SENSOR_MODE_VIDEO "VIDEO"
#define CSM_SENSOR_MODE_BODY_POINTING "BODY_POINTING"
namespace csm
{
namespace param
{
enum Type
//>
// This enumeration lists the possible model parameter or characteristic
// types as follows.
//
//- NONE - Parameter value has not yet been initialized.
//- FICTITIOUS - Parameter value has been calculated by resection
//- or other means.
//- REAL - Parameter value has been measured or read from
//- support data.
//- FIXED - Parameter value has been specified and is not
//- to be adjusted, but may contribute to error
//- propagation.
//
{
NONE = 0 ,
FICTITIOUS,
REAL,
FIXED
};
//<
enum Set
//>
// This enumeration lists the set of model parameters that a user may be
// interested in exploiting. Membership in one of these sets is
// determined by model parameter type.
//
//- VALID - Parameters of type NONE are excluded.
//- All others are included,
//- ADJUSTABLE - Only REAL or FICTICIOUS parameters are included.
//- NON_ADJUSTABLE - Only FIXED parameters are included.
//
{
VALID = 0,
ADJUSTABLE,
NON_ADJUSTABLE
};
//<
}
//***
// STRUCT: SharingCriteria
//> This structure stores information regarding whether or not a model
// parameter might be "shared" between models of the same type, based on
// common characteristics.
//<
//***
struct SharingCriteria
{
public:
bool matchesName;
//> Requires that the models have the same model name as given by
// the Model::getModelName method. Will almost always be set to true.
//<
bool matchesSensorID;
//> Requires that the models have the same sensor ID as given by
// the Model::getSensorIdentifier method.
//<
bool matchesPlatformID;
//> Requires that the models have the same platform ID as given by
// the Model::getPlatformIdentifier method.
//<
bool matchesCollectionID;
//> Requires that the models have the same collection ID as given by
// the Model::getCollectionIdentifier method.
//<
bool matchesTrajectoryID;
//> Requires that the models have the same trajectory ID as given by
// the Model::getTrajectoryIdentifier method.
//<
bool matchesDateTime;
//> Requires that the models' imaging times must be within a certain
// time delta. It is typically sufficient to compare the times at
// the start of the image.
//<
double maxTimeDelta;
//> Maximum time separation, in seconds, for a model parameter to be
// shared when matchesDateTime is true.
//<
SharingCriteria()
:
matchesName (false),
matchesSensorID (false),
matchesPlatformID (false),
matchesCollectionID (false),
matchesTrajectoryID (false),
matchesDateTime (false),
maxTimeDelta (0.0)
{}
SharingCriteria(bool byName,
bool bySensorID,
bool byPlatformID,
bool byCollectionID,
bool byTrajectoryID,
bool byDateTime,
double maxDelta)
:
matchesName (byName),
matchesSensorID (bySensorID),
matchesPlatformID (byPlatformID),
matchesCollectionID (byCollectionID),
matchesTrajectoryID (byTrajectoryID),
matchesDateTime (byDateTime),
maxTimeDelta (maxDelta)
{}
};
//***
// STRUCT: ImageCoord
//> This structure represents a two-dimensional image coordinate
// (line, sample in pixels).
// It typically represents an absolute coordinate.
//<
//***
struct ImageCoord
{
public:
double line;
double samp;
ImageCoord() : line(0.0), samp(0.0) {}
ImageCoord(double aLine, double aSamp) : line(aLine), samp(aSamp) {}
};
//***
// STRUCT: ImageCoordCovar
//> This structure represents an image coordinate with a corresponding
// 2x2 covariance matrix.
//
// The covariance is stored as an array of four elements that can be
// accessed directly or through the two-dimensional covar2d methods.
//<
//***
struct ImageCoordCovar : public ImageCoord
{
public:
double covariance[4];
//> 2x2 line and sample covariance matrix, in pixels squared,
// stored as an array of four doubles as follows:
//
//- [0] = line variance
//- [1] = line/sample covariance
//- [2] = sample/line covariance
//- [3] = sample variance
//
// It can be accessed directly or through the covar2d methods.
//<
ImageCoordCovar() : ImageCoord() { std::memset(covariance, 0, sizeof(covariance)); }
//> Default Constructor
//<
ImageCoordCovar(double aLine, double aSamp)
: ImageCoord(aLine, aSamp) { std::memset(covariance, 0, sizeof(covariance)); }
//> This constructor takes a line and sample in pixels.
// The covariance is set to zeroes.
//<
ImageCoordCovar(double aLine, double aSamp, double aCovar[4])
: ImageCoord(aLine, aSamp) { std::memcpy(covariance, aCovar, sizeof(covariance)); }
//> This constructor takes a line and sample in pixels and covariance
// as an array of four doubles in pixels squared.
// Note that no check is made to ensure symmetry of the covariance
// matrix.
//<
ImageCoordCovar(double aLine, double aSamp,
double aCovar00, double aCovar01,
double aCovar11)
: ImageCoord(aLine, aSamp)
{
covariance[0] = aCovar00;
covariance[1] = covariance[2] = aCovar01;
covariance[3] = aCovar11;
}
//> This constructor takes a line and sample in pixels and the
// upper-triangular portion of a covariance matrix in pixels squared.
// It is assumed that the covariance matrix is symmetric.
//<
double covar2d(unsigned int l, unsigned int s) const { return covariance[2*l + s]; }
//> This method provides a convenient two-dimensional access to
// the covariance. For example, the sample variance stored in
// covariance[3] could also be accessed as follows:
//
//- ImageCoordCovar coord;
//- double A = coord.covar2d(1,1);
//<
double& covar2d(unsigned int l, unsigned int s) { return covariance[2*l + s]; }
//> This method provides a convenient two-dimensional means of setting
// the covariance. For example, the sample variance stored in
// covariance[3] could also be set as follows:
//
//- ImageCoordCovar coord;
//- coord.covar2d(1,1) = 0.5;
//<
};
//***
// STRUCT: ImageVector
//> This structure represents a two-dimensional vector in image space.
// Units are pixels. It can be used to represent the size of an image.
//<
//***
struct ImageVector
{
public:
double line;
double samp;
ImageVector() : line(0.0), samp(0.0) {}
ImageVector(double aLine, double aSamp) : line(aLine), samp(aSamp) {}
};
//***
// STRUCT: EcefCoord
//> This structure represents a three-dimensional location (x,y,z in meters)
// in the Earth-Centered Earth-Fixed (ECEF) coordinate system.
// It typically represents an absolute coordinate; the EcefVector structure
// is used for velocity and direction vectors.
//<
//***
struct EcefCoord
{
public:
double x;
double y;
double z;
EcefCoord() : x(0.0), y(0.0), z(0.0) {}
EcefCoord(double aX, double aY, double aZ) : x(aX), y(aY), z(aZ) {}
};
//***
// STRUCT: EcefCoordCovar
//> This structure represents an ECEF coordinate with a corresponding
// 3x3 covariance matrix.
//
// The covariance is stored as an array of nine elements that can be
// accessed directly or through the two-dimensional covar2d methods.
//<
//***
struct EcefCoordCovar : public EcefCoord
{
public:
double covariance[9];
//> 3x3 ECEF coordinate covariance matrix, in meters squared,
// stored as an array of nine doubles as follows:
//
//- [0] = x variance
//- [1] = xy covariance
//- [2] = xz covariance
//- [3] = yx covariance
//- [4] = y variance
//- [5] = yz covariance
//- [6] = zx covariance
//- [7] = zy covariance
//- [8] = z variance
//
// It can be accessed directly or through the covar2d methods.
//<
EcefCoordCovar() : EcefCoord() { std::memset(covariance, 0, sizeof(covariance)); }
//> Default Constructor
//<
EcefCoordCovar(double aX, double aY, double aZ)
: EcefCoord(aX, aY, aZ) { std::memset(covariance, 0, sizeof(covariance)); }
//> This constructor takes ECEF x, y, and z values in meters.
// The covariance is set to zeroes.
//<
EcefCoordCovar(double aX, double aY, double aZ, double aCovar[9])
: EcefCoord(aX, aY, aZ) { std::memcpy(covariance, aCovar, sizeof(covariance)); }
//> This constructor takes ECEF x, y, and z values in meters and
// covariance as an array of nine doubles in meters squared.
// Note that no check is made to ensure symmetry of the covariance
// matrix.
//<
EcefCoordCovar(double aX, double aY, double aZ,
double aCovar00, double aCovar01, double aCovar02,
double aCovar11, double aCovar12,
double aCovar22)
: EcefCoord(aX, aY, aZ)
{
covariance[0] = aCovar00;
covariance[1] = covariance[3] = aCovar01;
covariance[2] = covariance[6] = aCovar02;
covariance[4] = aCovar11;
covariance[5] = covariance[7] = aCovar12;
covariance[8] = aCovar22;
}
//> This constructor takes a ECEF x, y, and z values in meters and the
// upper-triangular portion of a covariance matrix in meters squared.
// It is assumed that the covariance matrix is symmetric.
//<
double covar2d(unsigned int l, unsigned int s) const { return covariance[3*l + s]; }
//> This method provides a convenient two-dimensional access to
// the covariance. For example, the yz covariance stored in
// covariance[5] could also be accessed as follows:
//
//- ImageCoordCovar coord;
//- double A = coord.covar2d(1,2);
//<
double& covar2d(unsigned int l, unsigned int s) { return covariance[3*l + s]; }
//> This method provides a convenient two-dimensional means of setting
// the covariance. For example, the yz covariance stored in
// covariance[5] could also be set as follows:
//
//- ImageCoordCovar coord;
//- coord.covar2d(1,2) = 0.5;
//<
};
//***
// STRUCT: EcefVector
//> This structure represents a three-dimensional vector in the WGS-84 Earth
// Centered Earth Fixed coordinate system.
//
// Units of meters (distance), meters per second (velocity) and no units
// are appropriate for EcefVector.
//<
//***
struct EcefVector
{
public:
double x;
double y;
double z;
EcefVector() : x(0.0), y(0.0), z(0.0) {}
EcefVector(double aX, double aY, double aZ) : x(aX), y(aY), z(aZ) {}
};
//***
// STRUCT: EcefLocus
//> This structure contains an ECEF coordinate (in meters) and
// an ECEF direction vector.
//<
//***
struct EcefLocus
{
public:
EcefCoord point;
EcefVector direction;
EcefLocus() : point() , direction() {}
EcefLocus(const EcefCoord& argPoint,
const EcefVector& argDirection)
:
point (argPoint),
direction (argDirection)
{}
EcefLocus(double ptX , double ptY , double ptZ,
double dirX, double dirY, double dirZ)
:
point (ptX, ptY, ptZ),
direction(dirX,dirY,dirZ)
{}
};
} // namespace csm
#endif