forked from ngageoint/csm
-
Notifications
You must be signed in to change notification settings - Fork 13
/
RasterGM.h
538 lines (505 loc) · 25.2 KB
/
RasterGM.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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
//#############################################################################
//
// FILENAME: RasterGM.h
//
// CLASSIFICATION: Unclassified
//
// DESCRIPTION:
//
// Header for abstract class that is to provide a common interface from
// which CSM raster geometric models will inherit. It is derived from the
// GeometricModel class.
//
// LIMITATIONS: None
//
//
// SOFTWARE HISTORY:
// Date Author Comment
// ----------- ------ -------
// 27-Jun-2003 LMT Initial version.
// 01-Jul-2003 LMT Remove constants, error/warning
// and make methods pure virtual.
// CharType enum.
// 31-Jul-2003 LMT Change calls with a "&" to a "*",
// combined CharType with ParamType
// to create Param_CharType, //reordered
// methods to match API order, added
// systematic error methods.
// 06-Aug-2003 LMT Removed all Characteristic calls.
// 08-Oct 2003 LMT Added getImageSize calls
// 06-Feb-2004 KRW Incorporates changes approved by
// January and February 2004
// configuration control board.
// 30-Jul-2004 PW Initail API 3.1 version
// 01-Nov-2004 PW October 2004 CCB
// 22 Oct 2010 DSL CCB Change add getCurrentCrossCovarianceMatrix
// and getOriginalCrossCovarianceMatrix
// 22 Oct 2010 DSL CCB Change add getCurrentCrossCovarianceMatrix
// and getOriginalCrossCovarianceMatrix
// 25 Oct 2010 DSL CCB Change add getNumGeometricCorrectionSwitches,
// getGeometricCorrectionName,
// getCurrentGeometricCorrectionSwitch,
// and setCurrentGeometricCorrectionSwitch
// 25 Oct 2010 DSL CCB Change add getNumGeometricCorrectionSwitches,
// getGeometricCorrectionName,
// getCurrentGeometricCorrectionSwitch,
// and setCurrentGeometricCorrectionSwitch
// 02-Mar-2012 SCM Refactored interface.
// 02-Jul-2012 SCM Made getUnmodeledError() be implemented inline.
// 26-Sep-2012 JPK Split SensorModel class into GeometricModel and
// RasterGM classes. RasterGM is now the
// equivalent class to the previous SensorModel class.
// 26-Sep-2012 SCM Moved all sensor partials to this class.
// 30-Oct-2012 SCM Renamed to RasterGM.h
// 31-Oct-2012 SCM Moved getTrajectoryIdentifier() to Model. Moved
// unmodeled error methods to GeometricModel. Made
// compute partial methods const.
// 01-Nov-2012 SCM Moved unmodeled error methods back to RasterGM.
// 27-Nov-2012 JPK Cleaned up some comments, variable names and
// changed return type for getCovarianceModel() from
// pointer to const reference. Removed unused
// testAPIVersionSubclass().
// 29-Nov-2012 JPK Modified computeAllSensorPartials to return
// results for a specified ParamSet.
// 06-Dec-2012 JPK Changed ParamSet to param::Set. De-inlined
// destructor and getFamily() methods.
// Replaced vector<double> with EcefLocus for
// imageTo*Locus methods. Added inline method
// getCovarianceMatrix(). Provided reference
// implementations for computeAllSensorPartials()
// methods. Made getCovarianceModel() pure
// virtual.
// 17-Dec-2012 BAH Documentation updates.
// 12-Feb-2013 JPK Renamed CovarianceModel to CorrelationModel.
//
// NOTES:
//
//#############################################################################
#ifndef __CSM_RASTERGM_H
#define __CSM_RASTERGM_H
#include "GeometricModel.h"
#define CSM_RASTER_FAMILY "Raster"
namespace csm
{
class CorrelationModel;
class CSM_EXPORT_API RasterGM : public GeometricModel
{
public:
RasterGM() {}
virtual ~RasterGM();
virtual std::string getFamily() const;
//> This method returns the Family ID for the current model.
//<
//---
// Core Photogrammetry
//---
virtual ImageCoord groundToImage(const EcefCoord& groundPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This method converts the given groundPt (x,y,z in ECEF meters) to a
// returned image coordinate (line, sample in full image space pixels).
//
// Iterative algorithms will use desiredPrecision, in meters, as the
// convergence criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual ImageCoordCovar groundToImage(const EcefCoordCovar& groundPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This method converts the given groundPt (x,y,z in ECEF meters and
// corresponding 3x3 covariance in ECEF meters squared) to a returned
// image coordinate with covariance (line, sample in full image space
// pixels and corresponding 2x2 covariance in pixels squared).
//
// Iterative algorithms will use desiredPrecision, in meters, as the
// convergence criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual EcefCoord imageToGround(const ImageCoord& imagePt,
double height,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This method converts the given imagePt (line,sample in full image
// space pixels) and given height (in meters relative to the WGS-84
// ellipsoid) to a returned ground coordinate (x,y,z in ECEF meters).
//
// Iterative algorithms will use desiredPrecision, in meters, as the
// convergence criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual EcefCoordCovar imageToGround(const ImageCoordCovar& imagePt,
double height,
double heightVariance,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This method converts the given imagePt (line, sample in full image
// space pixels and corresponding 2x2 covariance in pixels squared)
// and given height (in meters relative to the WGS-84 ellipsoid) and
// corresponding heightVariance (in meters) to a returned ground
// coordinate with covariance (x,y,z in ECEF meters and corresponding
// 3x3 covariance in ECEF meters squared).
//
// Iterative algorithms will use desiredPrecision, in meters, as the
// convergence criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual EcefLocus imageToProximateImagingLocus(
const ImageCoord& imagePt,
const EcefCoord& groundPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This method, for the given imagePt (line, sample in full image space
// pixels), returns the position and direction of the imaging locus
// nearest the given groundPt (x,y,z in ECEF meters).
//
// Note that there are two opposite directions possible. Both are
// valid, so either can be returned; the calling application can convert
// to the other as necessary.
//
// Iterative algorithms will use desiredPrecision, in meters, as the
// convergence criterion for the locus position, otherwise it will be
// ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual EcefLocus imageToRemoteImagingLocus(
const ImageCoord& imagePt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This method, for the given imagePt (line, sample in full image space
// pixels), returns the position and direction of the imaging locus
// at the sensor.
//
// Note that there are two opposite directions possible. Both are
// valid, so either can be returned; the calling application can convert
// to the other as necessary.
//
// Iterative algorithms will use desiredPrecision, in meters, as the
// convergence criterion for the locus position, otherwise it will be
// ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//
// Notes:
//
// The remote imaging locus is only well-defined for optical sensors.
// It is undefined for SAR sensors and might not be available for
// polynomial and other non-physical models. The
// imageToProximateImagingLocus method should be used instead where
// possible.
//<
//---
// Monoscopic Mensuration
//---
virtual ImageCoord getImageStart() const = 0;
//> This method returns the starting coordinate (line, sample in full
// image space pixels) for the imaging operation. Typically (0,0).
//<
virtual ImageVector getImageSize() const = 0;
//> This method returns the number of lines and samples in full image
// space pixels for the imaging operation.
//
// Note that the model might not be valid over the entire imaging
// operation. Use getValidImageRange() to get the valid range of image
// coordinates.
//<
virtual std::pair<ImageCoord,ImageCoord> getValidImageRange() const = 0;
//> This method returns the minimum and maximum image coordinates
// (line, sample in full image space pixels), respectively, over which
// the current model is valid. The image coordinates define opposite
// corners of a rectangle whose sides are parallel to the line and
// sample axes.
//
// The valid image range does not always match the full image
// coverage as returned by the getImageStart and getImageSize methods.
//
// Used in conjunction with the getValidHeightRange method, it is
// possible to determine the full range of ground coordinates over which
// the model is valid.
//<
virtual std::pair<double,double> getValidHeightRange() const = 0;
//> This method returns the minimum and maximum heights (in meters
// relative to WGS-84 ellipsoid), respectively, over which the model is
// valid. For example, a model for an airborne platform might not be
// designed to return valid coordinates for heights above the aircraft.
//
// If there are no limits defined for the model, (-99999.0,99999.0)
// will be returned.
//<
virtual EcefVector getIlluminationDirection(const EcefCoord& groundPt) const = 0;
//> This method returns a vector defining the direction of
// illumination at the given groundPt (x,y,z in ECEF meters).
// Note that there are two opposite directions possible. Both are
// valid, so either can be returned; the calling application can convert
// to the other as necessary.
//<
//---
// Time and Trajectory
//---
virtual double getImageTime(const ImageCoord& imagePt) const = 0;
//> This method returns the time in seconds at which the pixel at the
// given imagePt (line, sample in full image space pixels) was captured
//
// The time provided is relative to the reference date and time given
// by the Model::getReferenceDateAndTime method.
//<
virtual EcefCoord getSensorPosition(const ImageCoord& imagePt) const = 0;
//> This method returns the position of the physical sensor
// (x,y,z in ECEF meters) when the pixel at the given imagePt
// (line, sample in full image space pixels) was captured.
//
// A csm::Error will be thrown if the sensor position is not available.
//<
virtual EcefCoord getSensorPosition(double time) const = 0;
//> This method returns the position of the physical sensor
// (x,y,z meters ECEF) at the given time relative to the reference date
// and time given by the Model::getReferenceDateAndTime method.
//<
virtual EcefVector getSensorVelocity(const ImageCoord& imagePt) const = 0;
//> This method returns the velocity of the physical sensor
// (x,y,z in ECEF meters per second) when the pixel at the given imagePt
// (line, sample in full image space pixels) was captured.
//<
virtual EcefVector getSensorVelocity(double time) const = 0;
//> This method returns the velocity of the physical sensor
// (x,y,z in ECEF meters per second ) at the given time relative to the
// reference date and time given by the Model::getReferenceDateAndTime
// method.
//<
//---
// Uncertainty Propagation
//---
typedef std::pair<double,double> SensorPartials;
//> This type is used to hold the partial derivatives of line and
// sample, respectively, with respect to a model parameter.
// The units are pixels per the model parameter units.
//<
virtual SensorPartials computeSensorPartials(
int index,
const EcefCoord& groundPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This is one of two overloaded methods. This method takes only
// the necessary inputs. Some effieciency can be obtained by using the
// other method. Even more efficiency can be obtained by using the
// computeAllSensorPartials method.
//
// This method returns the partial derivatives of line and sample
// (in pixels per the applicable model parameter units), respectively,
// with respect to the model parameter given by index at the given
// groundPt (x,y,z in ECEF meters).
//
// Derived model implementations may wish to implement this method by
// calling the groundToImage method and passing the resulting image
// coordinate to the other computeSensorPartials method.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the highest actual precision, in meters, achieved by
// iterative algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual SensorPartials computeSensorPartials(
int index,
const ImageCoord& imagePt,
const EcefCoord& groundPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This is one of two overloaded methods. This method takes
// an input image coordinate for efficiency. Even more efficiency can
// be obtained by using the computeAllSensorPartials method.
//
// This method returns the partial derivatives of line and sample
// (in pixels per the applicable model parameter units), respectively,
// with respect to the model parameter given by index at the given
// groundPt (x,y,z in ECEF meters).
//
// The imagePt, corresponding to the groundPt, is given so that it does
// not need to be computed by the method. Results are unpredictable if
// the imagePt provided does not correspond to the result of calling the
// groundToImage method with the given groundPt.
//
// Implementations with iterative algorithms (typically ground-to-image
// calls) will use desiredPrecision, in meters, as the convergence
// criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the highest actual precision, in meters, achieved by
// iterative algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual std::vector<SensorPartials> computeAllSensorPartials(
const EcefCoord& groundPt,
param::Set pSet = param::VALID,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const;
//> This is one of two overloaded methods. This method takes only
// the necessary inputs. Some effieciency can be obtained by using the
// other method.
//
// This method returns the partial derivatives of line and sample
// (in pixels per the applicable model parameter units), respectively,
// with respect to to each of the desired model parameters at the given
// groundPt (x,y,z in ECEF meters). Desired model parameters are
// indicated by the given pSet.
//
// Implementations with iterative algorithms (typically ground-to-image
// calls) will use desiredPrecision, in meters, as the convergence
// criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the highest actual precision, in meters, achieved by
// iterative algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//
// The value returned is a vector of pairs with line and sample partials
// for one model parameter in each pair. The indices of the
// corresponding model parameters can be found by calling the
// getParameterSetIndices method for the given pSet.
//
// Derived models may wish to implement this directly for efficiency,
// but an implementation is provided here that calls the
// computeSensorPartials method for each desired parameter index.
//<
virtual std::vector<SensorPartials> computeAllSensorPartials(
const ImageCoord& imagePt,
const EcefCoord& groundPt,
param::Set pSet = param::VALID,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const;
//> This is one of two overloaded methods. This method takes
// an input image coordinate for efficiency.
//
// This method returns the partial derivatives of line and sample
// (in pixels per the applicable model parameter units), respectively,
// with respect to to each of the desired model parameters at the given
// groundPt (x,y,z in ECEF meters). Desired model parameters are
// indicated by the given pSet.
//
// The imagePt, corresponding to the groundPt, is given so that it does
// not need to be computed by the method. Results are unpredictable if
// the imagePt provided does not correspond to the result of calling the
// groundToImage method with the given groundPt.
//
// Implementations with iterative algorithms (typically ground-to-image
// calls) will use desiredPrecision, in meters, as the convergence
// criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the highest actual precision, in meters, achieved by
// iterative algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//
// The value returned is a vector of pairs with line and sample partials
// for one model parameter in each pair. The indices of the
// corresponding model parameters can be found by calling the
// getParameterSetIndices method for the given pSet.
//
// Derived models may wish to implement this directly for efficiency,
// but an implementation is provided here that calls the
// computeSensorPartials method for each desired parameter index.
//<
virtual std::vector<double> computeGroundPartials(const EcefCoord& groundPt) const = 0;
//> This method returns the partial derivatives of line and sample
// (in pixels per meter) with respect to the given groundPt
// (x,y,z in ECEF meters).
//
// The value returned is a vector with six elements as follows:
//
//- [0] = line wrt x
//- [1] = line wrt y
//- [2] = line wrt z
//- [3] = sample wrt x
//- [4] = sample wrt y
//- [5] = sample wrt z
//<
virtual const CorrelationModel& getCorrelationModel() const = 0;
//> This method returns a reference to a CorrelationModel.
// The CorrelationModel is used to determine the correlation between
// the model parameters of different models of the same type.
// These correlations are used to establish the "a priori" cross-covariance
// between images. While some applications (such as generation of a
// replacement sensor model) may wish to call this method directly,
// it is reccommended that the inherited method
// GeometricModel::getCrossCovarianceMatrix() be called instead.
//<
inline std::vector<double> getUnmodeledError(const ImageCoord& imagePt) const
{ return getUnmodeledCrossCovariance(imagePt, imagePt); }
//> This method returns the 2x2 line and sample covariance (in pixels
// squared) at the given imagePt for any model error not accounted for
// by the model parameters.
//
// The value returned is a vector of four elements as follows:
//
//- [0] = line variance
//- [1] = line/sample covariance
//- [2] = sample/line covariance
//- [3] = sample variance
//<
virtual std::vector<double> getUnmodeledCrossCovariance(
const ImageCoord& pt1,
const ImageCoord& pt2) const = 0;
//> This method returns the 2x2 line and sample cross covariance
// (in pixels squared) between the given imagePt1 and imagePt2 for any
// model error not accounted for by the model parameters. The error is
// reported as the four terms of a 2x2 matrix, returned as a 4 element
// vector.
//<
};
} // namespace csm
#endif