diff --git a/ObjectSpace.cpp b/ObjectSpace.cpp new file mode 100644 index 0000000..076170c --- /dev/null +++ b/ObjectSpace.cpp @@ -0,0 +1,338 @@ +//#################################################################### +// +// FILENAME: ObjectSpace.cpp +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// Implementation for object space definition class and non-ECEF Object Space coordinate +// classes. +// +// LIMITATIONS: None +// +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 31-March-2022 Eugene Rose CCB Change CSM 3.0.4 +// +// NOTES: +// +//##################################################################### +#define CSM_LIBRARY +#include "csm.h" +#include "ObjectSpace.h" + +namespace csm +{ +//***************************************************************************** +// ObjectSpaceCoordinate::ObjectSpaceCoordinate (copy constructor) +//***************************************************************************** +ObjectSpaceCoordinate::ObjectSpaceCoordinate(const ObjectSpaceCoordinate& other) +{ + x = other.x; + y = other.y; + z = other.z; +} + +//***************************************************************************** +// ObjectSpaceCoordinate::operator= +//***************************************************************************** +ObjectSpaceCoordinate& ObjectSpaceCoordinate::operator=(const ObjectSpaceCoordinate& other) +{ + x = other.x; + y = other.y; + z = other.z; + return *this; +} + +//***************************************************************************** +// ObjectSpaceCoordinate::setCoordinate +//***************************************************************************** +void ObjectSpaceCoordinate::setCoordinate(double xArg, double yArg, double zArg) +{ + x = xArg; + y = yArg; + z = zArg; +} + +//***************************************************************************** +// ObjectSpaceCoordinateCovar::ObjectSpaceCoordinateCovar +//***************************************************************************** +ObjectSpaceCoordinateCovar::ObjectSpaceCoordinateCovar() +{ + x = 0; + y = 0; + z = 0; + std::memset(covariance, 0, sizeof(covariance)); +} + + +//***************************************************************************** +// ObjectSpaceCoordinateCovar::ObjectSpaceCoordinateCovar +//***************************************************************************** +ObjectSpaceCoordinateCovar::ObjectSpaceCoordinateCovar( + double aX, double aY, double aZ) +{ + x = aX; y = aY; z = aZ; + std::memset(covariance, 0, sizeof(covariance)); +} + +//***************************************************************************** +// ObjectSpaceCoordinateCovar::ObjectSpaceCoordinateCovar +//***************************************************************************** +ObjectSpaceCoordinateCovar::ObjectSpaceCoordinateCovar( + double aX, double aY, double aZ, const double aCovar[9]) +{ + x = aX; y = aY; z = aZ; + std::memcpy(covariance, aCovar, sizeof(covariance)); +} + +//***************************************************************************** +// ObjectSpaceCoordinateCovar::ObjectSpaceCoordinateCovar +//***************************************************************************** +ObjectSpaceCoordinateCovar::ObjectSpaceCoordinateCovar(double aX, double aY, double aZ, + double aCovar00, double aCovar01, double aCovar02, + double aCovar11, double aCovar12, + double aCovar22) +{ + x = aX; y = aY; z = 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; +} + +//***************************************************************************** +// ObjectSpaceCoordinateCovar::ObjectSpaceCoordinateCovar (copy constructor) +//***************************************************************************** +ObjectSpaceCoordinateCovar::ObjectSpaceCoordinateCovar(const ObjectSpaceCoordinateCovar& other) +{ + x = other.x; + y = other.y; + z = other.z; + std::memcpy(covariance, other.covariance, sizeof(covariance)); +} + +//***************************************************************************** +// ObjectSpaceCoordinateCovar::operator= +//***************************************************************************** +ObjectSpaceCoordinateCovar& ObjectSpaceCoordinateCovar::operator=(const ObjectSpaceCoordinateCovar& other) +{ + x = other.x; + y = other.y; + z = other.z; + std::memcpy(covariance, other.covariance, sizeof(covariance)); + return *this; +} + +//***************************************************************************** +// ObjectSpaceCoordinateCovar::setCoordinate +//***************************************************************************** +void ObjectSpaceCoordinateCovar::setCoordinate(double xArg, double yArg, double zArg) +{ + x = xArg; + y = yArg; + z = zArg; +} + +//***************************************************************************** +// ObjectSpaceCoordinateCovar::setCovariance +//***************************************************************************** +void ObjectSpaceCoordinateCovar::setCovariance(const double aCovar[9]) +{ + std::memcpy(covariance, aCovar, sizeof(covariance)); +} + +//***************************************************************************** +// ObjectSpaceVector::ObjectSpaceVector (copy constructor) +//***************************************************************************** +ObjectSpaceVector::ObjectSpaceVector(const ObjectSpaceVector& other) +{ + x = other.x; + y = other.y; + z = other.z; +} + +//***************************************************************************** +// ObjectSpaceVector::operator= +//***************************************************************************** +ObjectSpaceVector& ObjectSpaceVector::operator=(const ObjectSpaceVector& other) +{ + x = other.x; + y = other.y; + z = other.z; + return *this; +} + +//***************************************************************************** +// ObjectSpaceVector::setCoordinate +//***************************************************************************** +void ObjectSpaceVector::setCoordinate(double xArg, double yArg, double zArg) +{ + x = xArg; + y = yArg; + z = zArg; +} + +//***************************************************************************** +// ObjectSpaceVectorCovar::ObjectSpaceVectorCovar +//***************************************************************************** +ObjectSpaceVectorCovar::ObjectSpaceVectorCovar() +{ + x = 0.0; + y = 0.0; + z = 0.0; + std::memset(covariance, 0, sizeof(covariance)); +} + +//***************************************************************************** +// ObjectSpaceVectorCovar::ObjectSpaceVectorCovar +//***************************************************************************** +ObjectSpaceVectorCovar::ObjectSpaceVectorCovar(double aX, double aY, double aZ, + double aCovar[9]) +{ + x = aX; + y = aY; + z = aZ; + std::memcpy(covariance, aCovar, sizeof(covariance)); +} + +//***************************************************************************** +// ObjectSpaceVectorCovar::ObjectSpaceVectorCovar +//***************************************************************************** +ObjectSpaceVectorCovar::ObjectSpaceVectorCovar(double aX, double aY, double aZ, + double aCovar00, double aCovar01, double aCovar02, + double aCovar11, double aCovar12, + double aCovar22) +{ + x = aX; + y = aY; + z = 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; + +} + + +//***************************************************************************** +// ObjectSpaceVectorCovar::ObjectSpaceVectorCovar (copy constructor) +//***************************************************************************** +ObjectSpaceVectorCovar::ObjectSpaceVectorCovar(const ObjectSpaceVectorCovar& other) +{ + x = other.x; + y = other.y; + z = other.z; + std::memcpy(covariance, other.covariance, sizeof(covariance)); +} + +//***************************************************************************** +// ObjectSpaceVectorCovar::operator= +//***************************************************************************** +ObjectSpaceVectorCovar& ObjectSpaceVectorCovar::operator=(const ObjectSpaceVectorCovar& other) +{ + x = other.x; + y = other.y; + z = other.z; + std::memcpy(covariance, other.covariance, sizeof(covariance)); + + return *this; +} + +//***************************************************************************** +// ObjectSpaceVectorCovar::setCoordinate +//***************************************************************************** +void ObjectSpaceVectorCovar::setCoordinate(double xArg, double yArg, double zArg) +{ + x = xArg; + y = yArg; + z = zArg; +} + +//***************************************************************************** +// ObjectSpaceVectorCovar::setCovariance +//***************************************************************************** +void ObjectSpaceVectorCovar::setCovariance(const double aCovar[9]) +{ + std::memcpy(covariance, aCovar, sizeof(covariance)); +} + +//***************************************************************************** +// ObjectSpaceLocus::ObjectSpaceLocus (copy constructor) +//***************************************************************************** +ObjectSpaceLocus::ObjectSpaceLocus(const ObjectSpaceLocus& other) +{ + point = (other.point); // use assignment operator of ObjectSpacePoint + direction = (other.direction); // use assignment operator of ObjectSpaceVector +} + +//***************************************************************************** +// ObjectSpaceLocus::operator= +//***************************************************************************** +ObjectSpaceLocus& ObjectSpaceLocus::operator=(const ObjectSpaceLocus& other) +{ + point = (other.point); // use assignment operator of ObjectSpacePoint + direction = (other.direction); // use assignment operator of ObjectSpaceVector + return *this; +} + +//***************************************************************************** +// ObjectSpaceLocus::setPoint +//***************************************************************************** +void ObjectSpaceLocus::setPoint(const ObjectSpaceCoordinate& argPoint) +{ + point = argPoint; +} + +//***************************************************************************** +// ObjectSpaceLocus::setVector +//***************************************************************************** +void ObjectSpaceLocus::setVector(const ObjectSpaceVector& argDirection) +{ + direction = argDirection; +} + +//***************************************************************************** +// ObjectSpaceLocusCovar::ObjectSpaceLocusCovar (copy constructor) +//***************************************************************************** +ObjectSpaceLocusCovar::ObjectSpaceLocusCovar(const ObjectSpaceLocusCovar& other) +{ + point = (other.point); // use assignment operator of ObjectSpacePoint + direction = (other.direction); // use assignment operator of ObjectSpaceVector +} + +//***************************************************************************** +// ObjectSpaceLocusCovar::operator= +//***************************************************************************** +ObjectSpaceLocusCovar& ObjectSpaceLocusCovar::operator=(const ObjectSpaceLocusCovar& other) +{ + point = (other.point); // use assignment operator of ObjectSpacePoint + direction = (other.direction); // use assignment operator of ObjectSpaceVector + return *this; +} + +//***************************************************************************** +// ObjectSpaceLocusCovar::setPoint +//***************************************************************************** +void ObjectSpaceLocusCovar::setPoint(const ObjectSpaceCoordinateCovar& argPoint) +{ + point = argPoint; +} + +//***************************************************************************** +// ObjectSpaceLocusCovar::setVector +//***************************************************************************** +void ObjectSpaceLocusCovar::setVector(const ObjectSpaceVectorCovar& argDirection) +{ + direction = argDirection; +} + +} + diff --git a/ObjectSpace.h b/ObjectSpace.h new file mode 100644 index 0000000..8d84338 --- /dev/null +++ b/ObjectSpace.h @@ -0,0 +1,395 @@ +//#################################################################### +// +// FILENAME: ObjectSpace.h +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// Header for object space definition class and non-ECEF ObjectSpace coordinate classes. +// +// LIMITATIONS: None +// +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 31-March-2022 Eugene Rose CCB Change CSM 3.0.4 +// +// NOTES: +// +//##################################################################### + +#ifndef __CSM_OBJECTSPACE_H +#define __CSM_OBJECTSPACE_H + +namespace csm +{ +enum class CSM_EXPORT_API ObjectSpaceType : unsigned char +{ + LSR, + ECI, + UNDEFINED +}; +//> +// This enum class identifies the object space type. +//< + +//*** +// STRUCT: ObjectSpaceCoordinate +//> This structure represents a three-dimensional point in the object space coordinate system. +// +// Coordinate values are in units of meters. +//< +//*** +struct CSM_EXPORT_API ObjectSpaceCoordinate +{ +public: + double x; + double y; + double z; + //> three coordinate values + //< + + ObjectSpaceCoordinate() : + x(0.0), y(0.0), z(0.0) {} + //> the default constructor initializes the coordinates all to 0.0 + //< + + ObjectSpaceCoordinate(double aX, double aY, double aZ) : x(aX), y(aY), z(aZ) {} + //> constructor that initializes with the values given + //< + + ObjectSpaceCoordinate(const ObjectSpaceCoordinate& other); + //> + // copy constructor + //< + + ObjectSpaceCoordinate& operator=(const ObjectSpaceCoordinate& other); + //> + // assignment operator + //< + + void setCoordinate(double x, double y, double z); + //> + // set all three coordinate values + //< + +}; // ObjectSpaceCoordinate + +//*** +// STRUCT: ObjectCoordinateCovar +//> This structure represents a three-dimensional point in the object space coordinate system +// and its 3 by 3 covariance matrix. +// +// Coordinate values are in units of meters and covariances are in units of meters-squared. +//< +//*** +struct CSM_EXPORT_API ObjectSpaceCoordinateCovar +{ +public: + double x; + double y; + double z; + //> three coordinate values + //< + + double covariance[9]; +//> 3x3 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 +//< + + ObjectSpaceCoordinateCovar(); + //> Default Constructor + //< + + ObjectSpaceCoordinateCovar(double aX, double aY, double aZ); + //> This constructor takes x, y, and z values in meters. + // The covariance is set to zeroes. + //< + + ObjectSpaceCoordinateCovar(double aX, double aY, double aZ, const double aCovar[9]); + //> This constructor takes 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. + //< + + ObjectSpaceCoordinateCovar(double aX, double aY, double aZ, + double aCovar00, double aCovar01, double aCovar02, + double aCovar11, double aCovar12, + double aCovar22); + //> This constructor takes 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. + //< + + ObjectSpaceCoordinateCovar(const ObjectSpaceCoordinateCovar& other); + //> + // copy constructor + //< + + ObjectSpaceCoordinateCovar& operator=(const ObjectSpaceCoordinateCovar& other); + //> + // assignment operator + //< + + void setCoordinate(double x, double y, double z); + //> + // set all three coordinate values + //< + + void setCovariance(const double aCovar[9]); + //> + // set the covariance in an existing object + //< + +}; // ObjectSpaceCoordinateCovar + +//*** +// STRUCT: ObjectSpaceVector +//> This structure represents a three-dimensional vector in the object space coordinate system. +// +// Vector coordinates are in units of meters. +//< +//*** +struct CSM_EXPORT_API ObjectSpaceVector +{ +public: + double x; + double y; + double z; + //> these are the vector components in units of meters. + //< + + ObjectSpaceVector() : x(0.0), y(0.0), z(0.0) {} + //> This constructor takes x, y, and z values in meters. + // The covariance is set to zeroes. + //< + ObjectSpaceVector(double aX, double aY, double aZ) : x(aX), y(aY), z(aZ) {} + //> constructor that initializes with the values given + //< + + ObjectSpaceVector(const ObjectSpaceVector& other); + //> + // copy constructor + //< + + ObjectSpaceVector& operator=(const ObjectSpaceVector& other); + //> + // assignment operator + //< + + void setCoordinate(double x, double y, double z); + //> + // set all three coordinate values + //< + +}; + +//*** +// STRUCT: ObjectSpaceVectorCovar +//> This structure represents a three-dimensional vector and its 3 by 3 covariance matrix +// in the object space coordinate system. +// +// Vector coordinates are in units of meters and covariances are in units of meters-squared. +//< +//*** +struct CSM_EXPORT_API ObjectSpaceVectorCovar +{ +public: + double x; + double y; + double z; + //> these are the vector components in units of meters. + //< + + double covariance[9]; + //> 3x3 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 + //< + + ObjectSpaceVectorCovar(); + //> default constructor initializes coordinates and covariances to 0.0 + //< + + ObjectSpaceVectorCovar(double aX, double aY, double aZ, double covar[9]); + //> constructor that initializes with the values given + //< + + ObjectSpaceVectorCovar(double aX, double aY, double aZ, + double aCovar00, double aCovar01, double aCovar02, + double aCovar11, double aCovar12, + double aCovar22); + //> This constructor takes 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. + //< + + ObjectSpaceVectorCovar(const ObjectSpaceVectorCovar& other); + //> + // copy constructor + //< + + ObjectSpaceVectorCovar& operator=(const ObjectSpaceVectorCovar& other); + //> + // assignment operator + //< + + void setCoordinate(double x, double y, double z); + //> + // set all three coordinate values + //< + + void setCovariance(const double aCovar[9]); + //> + // set the covariance in an existing object + //< +}; + +//*** +// STRUCT: ObjectSpaceLocus +//> This structure contains an object space coordinate (in meters) and +// an object space direction vector. +//< +//*** +struct CSM_EXPORT_API ObjectSpaceLocus +{ +public: + ObjectSpaceCoordinate point; + //> the origin point of the locus vector. + //< + + ObjectSpaceVector direction; + //> the three components of the direction vector. + //< + + ObjectSpaceLocus() : point(), direction() {} + //< the default constructors set all of the initial values to 0.0. + //> + + + ObjectSpaceLocus(const ObjectSpaceCoordinate& argPoint, + const ObjectSpaceVector& argDirection) + : + point(argPoint), + direction(argDirection) + {} + //> construct with the values given + //< + + ObjectSpaceLocus( double ptX, double ptY, double ptZ, + double dirX, double dirY, double dirZ) + : + point(ptX, ptY, ptZ), + direction(dirX, dirY, dirZ) + {} + //> construct with the coordinate values and vector components given. + //< + + ObjectSpaceLocus(const ObjectSpaceLocus& other); + //> + // copy constructor + //< + + ObjectSpaceLocus& operator=(const ObjectSpaceLocus& other); + //> + // assignment operator + //< + + void setPoint(const ObjectSpaceCoordinate& argPoint); + //> + // set the point in an existing object + //< + + void setVector(const ObjectSpaceVector& argDirection); + //> + // set the direction in an existing object + //< +}; + + +//*** +// STRUCT: ObjectSpaceLocusCovar +//> This structure contains an object space coordinate (in meters) and +// an object space direction vector. +//< +//*** +struct CSM_EXPORT_API ObjectSpaceLocusCovar +{ +public: + ObjectSpaceCoordinateCovar point; + //> the origin point of the locus vector. + //< + + ObjectSpaceVectorCovar direction; + //> the three components of the direction vector. + //< + + ObjectSpaceLocusCovar() : point(), direction() {} + //< the default constructors set all of the initial values to 0.0. + //> + + ObjectSpaceLocusCovar(const ObjectSpaceCoordinateCovar& argPoint, + const ObjectSpaceVectorCovar& argDirection) + : + point(argPoint), + direction(argDirection) + {} + //> construct with the values given + //< + + ObjectSpaceLocusCovar(double ptX, double ptY, double ptZ, double pt_covar[9], + double dirX, double dirY, double dirZ, double dir_covar[9]) + : + point(ptX, ptY, ptZ,pt_covar), + direction(dirX, dirY, dirZ, dir_covar) + {} + //> construct with the coordinate values and vector components given. + //< + + ObjectSpaceLocusCovar(const ObjectSpaceLocusCovar& other); + //> + // copy constructor + //< + + ObjectSpaceLocusCovar& operator=(const ObjectSpaceLocusCovar& other); + //> + // assignment operator + //< + + + void setPoint(const ObjectSpaceCoordinateCovar& argPoint); + //> + // set the point in an existing object + //< + + void setVector(const ObjectSpaceVectorCovar& argDirection); + //> + // set the direction in an existing object + //< + +}; + +} // namespace csm +#endif // __CSM_OBJECTSPACE_H diff --git a/ObjectSpacePointCloudGM.cpp b/ObjectSpacePointCloudGM.cpp new file mode 100644 index 0000000..c93a728 --- /dev/null +++ b/ObjectSpacePointCloudGM.cpp @@ -0,0 +1,139 @@ +//############################################################################# +// +// FILENAME: ObjectSpacePointCloudGM.cpp +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// This file provides implementation for methods declared in the +// ObjectSpacePointCloudGM class. +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 31-Dec-2021 EJR Initial Coding +// +// NOTES: +// +// Refer to ObjectSpacePointCloudGM.h for more information. +// +//############################################################################# +#define CSM_LIBRARY + +#include "GeometricModel.h" +#include "ObjectSpacePointCloudGM.h" + +namespace csm { +ObjectSpacePointCloudGM::ObjectSpacePointCloudGM() { }; + +std::string ObjectSpacePointCloudGM::getFamily()const { + return (GeometricModel::getFamily() + CSM_OSPC_FAMILY); +} + + +//***************************************************************************** +// ObjectSpacePointCloudGM::computeAllSensorPartials() +//***************************************************************************** + +std::vector ObjectSpacePointCloudGM::computeAllSensorPartials( + const ObjectSpaceCoordinate& groundPt, + param::Set pSet, + double desiredPrecision, + double* achievedPrecision, + WarningList* warnings) const +{ + const std::vector indices = csm::GeometricModel::getParameterSetIndices(pSet); + + std::vector val; + + const size_t NUM_PARAMS = indices.size(); + + if (NUM_PARAMS) + { + val.resize(NUM_PARAMS); + + //*** + // The achieved precision should be the MAXIMUM of the achieved + // precision values found for each desired index. + //*** + if (achievedPrecision) *achievedPrecision = 0.0; + + /* + virtual ModelCoord objectSpaceToModel(const ObjectSpaceCoordinate& groundPt, + double desiredPrecision = 0.001, + double* achievedPrecision = NULL, + WarningList* warnings = NULL) const = 0; + */ + double osToMPrecision = 0.0; + ModelCoord mc = objectSpaceToModel(groundPt,desiredPrecision,&osToMPrecision); + if (achievedPrecision && (osToMPrecision > desiredPrecision)) + { + *achievedPrecision = osToMPrecision; + } + + for (int i = 0; i < NUM_PARAMS; ++i) + { + double prec = 0.0; + val[i] = computeSensorPartials(indices[i], + mc, + groundPt, + desiredPrecision, + &prec, + warnings); + + if (achievedPrecision && (prec > *achievedPrecision)) + { + *achievedPrecision = prec; + } + } + } + return val; +}; + +//***************************************************************************** +// ObjectSpacePointCloudGM::computeAllSensorPartials() +//***************************************************************************** +std::vector ObjectSpacePointCloudGM::computeAllSensorPartials( + const ModelCoord& modelPt, + const ObjectSpaceCoordinate& groundPt, + param::Set pSet, + double desiredPrecision, + double* achievedPrecision, + WarningList* warnings) const +{ + const std::vector indices = csm::GeometricModel::getParameterSetIndices(pSet); + + std::vector val; + + const size_t NUM_PARAMS = indices.size(); + + if (NUM_PARAMS) + { + val.resize(NUM_PARAMS); + + //*** + // The achieved precision should be the MAXIMUM of the achieved + // precision values found for each desired index. + //*** + if (achievedPrecision) *achievedPrecision = 0.0; + + for (int i = 0; i < NUM_PARAMS; ++i) + { + double prec = 0.0; + val[i] = computeSensorPartials(indices[i], + modelPt, + groundPt, + desiredPrecision, + &prec, + warnings); + + if (achievedPrecision && (prec > *achievedPrecision)) + { + *achievedPrecision = prec; + } + } + } + return val; +} +} \ No newline at end of file diff --git a/ObjectSpacePointCloudGM.h b/ObjectSpacePointCloudGM.h new file mode 100644 index 0000000..18a9803 --- /dev/null +++ b/ObjectSpacePointCloudGM.h @@ -0,0 +1,395 @@ + +//############################################################################# +// +// FILENAME: ObjectSpacePointCloudGM.h +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// Header for abstract class that is to provide a common interface from +// which CSM point cloud geometric models that operate in non ECEF +// coordinate systems will inherit. It is derived from the +// GeometricModel class. +// +// LIMITATIONS: None +// +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 31-Dec-2021 EJR Initial version. +// +// NOTES: +// +//############################################################################# + +#ifndef __CSM_OBJECT_POINTCLOUD_GM_H +#define __CSM_OBJECT_POINTCLOUD_GM_H + +#include "csm.h" +#include "ObjectSpace.h" +#include "csmPointCloud.h" +#define CSM_OSPC_FAMILY "ObjectSpacePointCloud" + +namespace csm { + +class CorrelationModel; + +class CSM_EXPORT_API ObjectSpacePointCloudGM : public GeometricModel { +public: + ObjectSpacePointCloudGM(); + virtual ~ObjectSpacePointCloudGM() { } + + virtual std::string getFamily() const; + //> This method returns the Family ID for the current model. + //< + + virtual Version getVersion() const = 0; + //> get the protected data member that defines the specifics + // of the LSR object space being used by the model. + //< + + //--- + // Model-space description + //--- + virtual ModelCoordProperties getModelCoordinateProperties() const = 0; + //> This method returns a structure containing human-readable + // descriptions of the model-space coordinate system used by this + // sensor model. See the definition of ModelCoordProperties for an + // example of how it might be initialized. + //< + + // replace Geometric versions which are ecef-based + virtual ObjectSpaceCoordinate getObjectSpaceReferencePoint() const = 0; + //> This method returns the ground point indicating the general + // location of the image. + //< + + virtual void setObjectSpaceReferencePoint(const ObjectSpaceCoordinate& groundPt) = 0; + //> This method sets the ground point indicating the general location + // of the image. + //< + + //--- + // Core Transformations + //--- + virtual ModelCoord objectSpaceToModel(const ObjectSpaceCoordinate& groundPt, + double desiredPrecision = 0.001, + double* achievedPrecision = NULL, + WarningList* warnings = NULL) const = 0; + //> This method converts the given groundPt (x,y,z in meters) to a + // returned model coordinate (m0,m1,m2 in the model's coordinate + // space). + // + // 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 ModelCoordCovar objectSpaceToModel(const ObjectSpaceCoordinateCovar& groundPt, + double desiredPrecision = 0.001, + double* achievedPrecision = NULL, + WarningList* warnings = NULL) const = 0; + //> This method converts the given groundPt (x,y,z in meters and + // corresponding 3x3 covariance in meters squared) to a returned + // model coordinate with covariance (m0,m1,m2 in the model's + // coordinate space and corresponding 3x3 covariance). + // + // 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 ObjectSpaceCoordinate modelToObjectSpace(const ModelCoord& modelPt, + double desiredPrecision = 0.001, + double* achievedPrecision = NULL, + WarningList* warnings = NULL) const = 0; + //> This method converts the given modelPt (m0,m1,m2 in model + // coordinates) to a returned ground coordinate (x,y,z in 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 ObjectSpaceCoordinateCovar modelToObjectSpace(const ModelCoordCovar& modelPt, + double desiredPrecision = 0.001, + double* achievedPrecision = NULL, + WarningList* warnings = NULL) const = 0; + //> This method converts the given modelPt (m0,m1,m2 in model + // coordinates) and corresponding 3x3 covariance to a returned ground + // coordinate with covariance (x,y,z in meters and corresponding + // 3x3 covariance in 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. + //< + + //--- + // Model bounds + //--- + virtual ModelBounds getValidModelBounds() const = 0; + //> This method returns an object representing the model-space region + // over which the current model is valid. The ModelBounds object has a + // contains() function that may be used to check whether a given model + // coordinate lies within this region. + // + // NOTE: Attempting to use the model for transformations involving model + // coordinates outside the returned bounds may result in incorrect or + // misleading error estimates! + //< + + //--- + // Uncertainty Propagation + //--- + struct SensorPartials + { + double dM0; + double dM1; + double dM2; + }; + //> This type is used to hold the partial derivatives of model + // coordinates m0, m1, and m2, respectively, with respect to a model + // parameter. + //< + + + virtual SensorPartials computeSensorPartials(int index, + const ObjectSpaceCoordinate& 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 efficiency may be obtained by using the + // other method. Even more efficiency may be obtained by using the + // computeAllSensorPartials method. + // + // This method returns the partial derivatives of m0, m1, and m2 (in + // model coordinates) with respect to the model parameter given by + // index, at the given groundPt (x,y,z in 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 warnings argument is received, it will be populated + // as applicable. + //< + + virtual SensorPartials computeSensorPartials(int index, + const ModelCoord& modelPt, + const ObjectSpaceCoordinate& 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 model coordinate for efficiency. Even more efficiency may + // be obtained by using the computeAllSensorPartials method. + // + // This method returns the partial derivatives of m0, m1, and m2 (in + // model coordinates) with respect to the model parameter given by + // index, at the given groundPt (x,y,z in meters). + // + // The modelPt, corresponding to the groundPt, is given so that it does + // not need to be computed by the method. Results are undefined if + // the modelPt provided does not correspond to the result of calling the + // groundToModel 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 computeAllSensorPartials(const ObjectSpaceCoordinate& 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 efficiency may be obtained by using the + // other method. + // + // This method returns the partial derivatives of m0, m1, and m2 (in + // model coordinates) with respect to each of the model parameters at + // the given groundPt (x,y,z in 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 structures with m0, m1, and m2 + // partials for one model parameter in each structure. 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 computeAllSensorPartials(const ModelCoord& modelPt, + const ObjectSpaceCoordinate& 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 m0, m1, and m2 (in + // model coordinates) with respect to each of the model parameters at + // the given groundPt (x,y,z in meters). Desired model parameters + // are indicated by the given pSet. + // + // The modelPt, corresponding to the groundPt, is given so that it does + // not need to be computed by the method. Results are undefined if + // the modelPt provided does not correspond to the result of calling the + // groundToModel 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 structures with m0, m1, and m2 + // partials for one model parameter in each structure. 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 computeObjectSpacePartials(const ObjectSpaceCoordinate& groundPt) const = 0; + //> This method returns the partial derivatives of model coordinates m0, + // m1, m2 with respect to the given groundPt (x,y,z in meters). + // + // The value returned is a vector with nine elements as follows: + // + //- [0] = partial derivative of m0 with respect to x + //- [1] = partial derivative of m0 with respect to y + //- [2] = partial derivative of m0 with respect to z + //- [3] = partial derivative of m1 with respect to x + //- [4] = partial derivative of m1 with respect to y + //- [5] = partial derivative of m1 with respect to z + //- [6] = partial derivative of m2 with respect to x + //- [7] = partial derivative of m2 with respect to y + //- [8] = partial derivative of m2 with respect to z + //< + + virtual const CorrelationModel& getCorrelationModel() const = 0; + //> This method returns a reference to a correlation model. + // The correlation model is used to determine the correlation between + // the model parameters of different models of the same type. + // It is primarily used for replacement sensor model generation; + // most applications will use the getCrossCovarianceMatrix function. + //< + + inline std::vector getUnmodeledError(const ModelCoord& modelPt) const; + //> This method returns the 3x3 covariance matrix (in model coordinates) + // at the given modelPt for any model error not accounted for by the + // model parameters. + // + // The value returned is a vector of nine elements as follows: + // + //- [0] = m0 variance + //- [1] = m0/m1 covariance + //- [2] = m0/m2 covariance + //- [3] = m1/m0 covariance + //- [4] = m1 variance + //- [5] = m1/m2 covariance + //- [6] = m2/m0 covariance + //- [7] = m2/m1 covariance + //- [8] = m2 variance + //< + + virtual std::vector getUnmodeledCrossCovariance(const ModelCoord& pt1, + const ModelCoord& pt2) const = 0; + //> This method returns the 3x3 cross-covariance matrix (in model + // coordinates) between model points pt1 and pt2 for any model error not + // accounted for by the model parameters. + // + // The value returned is a vector of nine elements as follows: + // + //- [0] = pt1.m0/pt2.m0 covariance + //- [1] = pt1.m0/pt2.m1 covariance + //- [2] = pt1.m0/pt2.m2 covariance + //- [3] = pt1.m1/pt2.m0 covariance + //- [4] = pt1.m1/pt2.m1 covariance + //- [5] = pt1.m1/pt2.m2 covariance + //- [6] = pt1.m2/pt2.m0 covariance + //- [7] = pt1.m2/pt2.m1 covariance + //- [8] = pt1.m2/pt2.m2 covariance + //< + + ObjectSpaceType getObjectSpaceDefinition() const; + //> get the protected data member that defines the specifics + // of the LSR object space being used by the model. + //< + +}; + +//***************************************************************************** +// PointCloudGM::getUnmodeledError +//***************************************************************************** +inline std::vector ObjectSpacePointCloudGM::getUnmodeledError(const ModelCoord& modelPt) const +{ + return getUnmodeledCrossCovariance(modelPt, modelPt); +} + + +} // namespace csm + +#endif // __CSM_OBJECT_POINTCLOUD_GM_H diff --git a/ObjectSpaceRasterGM.cpp b/ObjectSpaceRasterGM.cpp new file mode 100644 index 0000000..812bcb7 --- /dev/null +++ b/ObjectSpaceRasterGM.cpp @@ -0,0 +1,137 @@ +//############################################################################# +// +// FILENAME: ObjectSpaceRasterGM.cpp +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// This file provides implementation for methods declared in the +// ObjectSpaceRasterGM class. +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 31-Dec-2021 EJR Initial Coding +// +// NOTES: +// +// Refer to ObjectSpaceRasterGM.h for more information. +// +//############################################################################# +#define CSM_LIBRARY + +#include "GeometricModel.h" +#include "ObjectSpaceRasterGM.h" + +namespace csm { +//***************************************************************************** +// ObjectSpaceRasterGM::ObjectSpaceRasterGM +//***************************************************************************** +ObjectSpaceRasterGM::ObjectSpaceRasterGM() { }; + +//***************************************************************************** +// ObjectSpaceRasterGM::getFamily +//***************************************************************************** +std::string ObjectSpaceRasterGM::getFamily()const { + return (GeometricModel::getFamily() + CSM_OSRASTER_FAMILY); +} + +//***************************************************************************** +// ObjectSpaceRasterGM::computeAllSensorPartials +//***************************************************************************** +std::vector ObjectSpaceRasterGM::computeAllSensorPartials( + const ObjectSpaceCoordinate& objectSpacePt, + param::Set pSet /* =param::VALID */, + double desiredPrecision /* =0.001 */, + double* achievedPrecision /* = NULL */, + WarningList* warnings) const +{ + const std::vector indices = csm::GeometricModel::getParameterSetIndices(pSet); + + std::vector val; + + const size_t NUM_PARAMS = indices.size(); + + if (NUM_PARAMS) + { + val.resize(NUM_PARAMS); + + //*** + // The achieved precision should be the MAXIMUM of the achieved + // precision values found for each desired index. + //*** + if (achievedPrecision) *achievedPrecision = 0.0; + + double osToIPrecision = 0.0; + ImageCoord ip = objectSpaceToImage(objectSpacePt,desiredPrecision,&osToIPrecision); + if (achievedPrecision && (osToIPrecision > desiredPrecision)) + { + *achievedPrecision = osToIPrecision; + } + for (int i = 0; i < NUM_PARAMS; ++i) + { + double prec = 0.0; + val[i] = computeSensorPartials(indices[i], + ip, + objectSpacePt, + desiredPrecision, + &prec, + warnings); + + if (achievedPrecision && (prec > *achievedPrecision)) + { + *achievedPrecision = prec; + } + } + } + return val; +}; + +//***************************************************************************** +// ObjectSpaceRasterGM::computeAllSensorPartials +//***************************************************************************** +std::vector ObjectSpaceRasterGM::computeAllSensorPartials( + const ImageCoord& imagePt, + const ObjectSpaceCoordinate& objectSpacePt, + param::Set pSet /* = param::VALID */, + double desiredPrecision /* = 0.001 */, + double* achievedPrecision /* = NULL */, + WarningList* warnings) const +{ + const std::vector indices = csm::GeometricModel::getParameterSetIndices(pSet); + + std::vector val; + + const size_t NUM_PARAMS = indices.size(); + + if (NUM_PARAMS) + { + val.resize(NUM_PARAMS); + + //*** + // The achieved precision should be the MAXIMUM of the achieved + // precision values found for each desired index. + //*** + if (achievedPrecision) *achievedPrecision = 0.0; + + for (int i = 0; i < NUM_PARAMS; ++i) + { + double prec = 0.0; + val[i] = computeSensorPartials(indices[i], + imagePt, + objectSpacePt, + desiredPrecision, + &prec, + warnings); + + if (achievedPrecision && (prec > *achievedPrecision)) + { + *achievedPrecision = prec; + } + } + } + return val; +} + +} \ No newline at end of file diff --git a/ObjectSpaceRasterGM.h b/ObjectSpaceRasterGM.h new file mode 100644 index 0000000..b0a98e6 --- /dev/null +++ b/ObjectSpaceRasterGM.h @@ -0,0 +1,520 @@ + +//############################################################################# +// +// FILENAME: ObjectSpaceRasterGM.h +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// Header for abstract class that is to provide a common interface from +// which CSM raster geometric models that operate in non ECEF +// coordinate systems will inherit. It is derived from the +// GeometricModel class. +// +// LIMITATIONS: None +// +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 31-MAR 22 EJR Initial version. +// +// NOTES: +// +//############################################################################# + +#ifndef __CSM_OBJECTRASTERGM_H +#define __CSM_OBJECTRASTERGM_H + +#include "csm.h" +#include "ProjectionParameters.h" +#include "Error.h" +#include "GeometricModel.h" +#include "ObjectSpace.h" +#define CSM_OSRASTER_FAMILY "ObjectSpaceRasterGM" + +namespace csm +{ +class CorrelationModel; + +class CSM_EXPORT_API ObjectSpaceRasterGM : public GeometricModel +{ +public: + ObjectSpaceRasterGM(); + //> + // default ctor does nothing + //< + + virtual ~ObjectSpaceRasterGM() {}; + //> + // need a desctructor realization so that subclass destructors have + //< something to call when they are destroyed. + + std::string getFamily()const; + //> This method returns the Family ID for the current model. + //< + + virtual Version getVersion() const = 0; + //> This method returns the version of the model code. The Version + // object can be compared to other Version objects with its comparison + // operators. Not to be confused with the CSM API version. + //< + + // these two methods supplement the methods in GeometricModel which work + // in ECEF space. + virtual ObjectSpaceCoordinate getObjectSpaceReferencePoint() const = 0; + //> This method returns the object space point indicating the general + // location of the image. + //< + + virtual void setObjectSpaceReferencePoint(const ObjectSpaceCoordinate& objectSpacePt) = 0; + //> This method sets the object space point indicating the general location + // of the image. + //< + //--- + // Core Photogrammetry + //--- + virtual ImageCoord objectSpaceToImage(const ObjectSpaceCoordinate& objectSpacePt, + double desiredPrecision = 0.001, + double* achievedPrecision = NULL, + WarningList* warnings = NULL) const = 0; + //> This method converts the given objectSpacePt (x,y,z in Object Space meters) to a + // returned image coordinate (line, sample in full image space pixels). + // + // Iterative algorithms will use desiredPrecision, in pixels, 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 pixels, 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 objectSpaceToImageCovar(const ObjectSpaceCoordinateCovar & objectSpacePt, + double desiredPrecision = 0.001, + double* achievedPrecision = NULL, + WarningList* warnings = NULL) const = 0; + //> This method converts the given objectSpacePt (x,y,z in meters and + // corresponding 3x3 covariance in 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 pixels, 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 pixels, 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 ObjectSpaceCoordinate imageToObjectSpace(const ImageCoord& imagePt, + const ProjectionParameters *geometry, + 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 projection parameters to a returned + // object space coordinate (x,y,z in Object Space meters). + // + // Iterative algorithms will use desiredPrecision, in pixels, 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 pixels, 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 ObjectSpaceCoordinateCovar imageToObjectSpaceCovar(const ImageCoordCovar& imagePt, + const ProjectionParametersCovar *geometry, + 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 projetion parameters with covariances to a returned object space + // coordinate with covariance (x,y,z in Object Space meters and corresponding + // 3x3 covariance in Object Space meters squared). + // + // Iterative algorithms will use desiredPrecision, in pixels, 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 pixels, 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 ObjectSpaceLocus imageToProximateObjectSpaceImagingLocus( + const ImageCoord& imagePt, + const ObjectSpaceCoordinate& objectSpacePt, + 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 objectSpacePt (x,y,z in Object Space 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 ObjectSpaceLocus imageToRemoteGroundSpaceImagingLocus( + 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. + //< + using ImageCoordPair = std::pair; + virtual ImageCoordPair 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 getValidRangeRange() const = 0; + //> This method returns the minimum and maximum range (in meters + // relative to the sensor position), respectively, over which the model is + // valid. + // + // If there are no limits defined for the model, (-99999.0,99999.0) + // will be returned. + //< + + virtual ObjectSpaceVector getIlluminationDirection(const ObjectSpaceCoordinate& objectSpacePt) const = 0; + //> This method returns a vector defining the direction of + // illumination at the given objectSpacePt (x,y,z in Object Space 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 ObjectSpaceCoordinate getSensorPosition(const ImageCoord& imagePt) const = 0; + //> This method returns the position of the physical sensor + // (x,y,z in Object Space meters) when the pixel at the given imagePt + // (line, sample in full image space pixels) was captured. + // + //< + + virtual ObjectSpaceCoordinate getSensorPosition(double time) const = 0; + //> This method returns the position of the physical sensor + // (x,y,z Object Space meters) at the given time relative to the reference date + // and time given by the Model::getReferenceDateAndTime method. + //< + + virtual ObjectSpaceVector getSensorVelocity(const ImageCoord& imagePt) const = 0; + //> This method returns the velocity of the physical sensor + // (x,y,z in Object Space meters per second) when the pixel at the given imagePt + // (line, sample in full image space pixels) was captured. + //< + + virtual ObjectSpaceVector getSensorVelocity(double time) const = 0; + //> This method returns the velocity of the physical sensor + // (x,y,z in Object Space 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 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 ObjectSpaceCoordinate& objectSpacePt, + 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 + // objectSpacePt (x,y,z in Object Space 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 ObjectSpaceCoordinate& objectSpacePt, + 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 + // objectSpacePt (x,y,z in Object Space meters). + // + // The imagePt, corresponding to the objectSpacePt, 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 objectSpacePt. + // + // 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 computeAllSensorPartials( + const ObjectSpaceCoordinate& objectSpacePt, + param::Set pSet = param::VALID, + 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. + // + // 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 + // objectSpacePt (x,y,z in Object Space 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 computeAllSensorPartials( + const ImageCoord& imagePt, + const ObjectSpaceCoordinate& objectSpacePt, + param::Set pSet = param::VALID, + 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. + // + // 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 + // objectSpacePt (x,y,z in Object Space meters). Desired model parameters are + // indicated by the given pSet. + // + // The imagePt, corresponding to the objectSpacePt, 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 objectSpacePt. + // + // 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 computeGroundPartials( + const ObjectSpaceCoordinate& objectSpacePt) const = 0; + //> This method returns the partial derivatives of line and sample + // (in pixels per meter) with respect to the given objectSpacePt + // (x,y,z in Object Space 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 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 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. + //< }; + + virtual ObjectSpaceType getObjectSpaceDefinition() const = 0; + //> get the protected data member that defines which + // object space being used by the model. + //< + +}; + +} // namespace csm + +#endif // __CSM_OBJECTRASTERGM_H diff --git a/ProjectionParameters.cpp b/ProjectionParameters.cpp new file mode 100644 index 0000000..d68e1a7 --- /dev/null +++ b/ProjectionParameters.cpp @@ -0,0 +1,237 @@ +//############################################################################# +// +// FILENAME: ProjectionParameters.cpp +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// This file provides implementation for helper methods associated with +// object space single image projection parameters. +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 31-Dec-2021 Rose Initial Coding CSM 3.0.4 +// +//############################################################################# +#define CSM_LIBRARY + +#include "ProjectionParameters.h" + + +namespace csm +{ + +//***************************************************************************** +// RangeParameters::RangeParameters() +//***************************************************************************** +ProjectionGeometryType RangeParameters::getType() const +{ + return ProjectionGeometryType::RANGE; +} + +//***************************************************************************** +// RangeParameters::RangeParameters() +//***************************************************************************** +RangeParameters::RangeParameters() +{ + m_range = 0.0; +} + +//***************************************************************************** +// RangeParameters::RangeParameters(double range) +//***************************************************************************** +RangeParameters::RangeParameters(double range) +{ + m_range = range; +} + +//***************************************************************************** +// RangeParameters::getrange +//***************************************************************************** +const double &RangeParameters::getRange() const +{ + return m_range; +} + +//***************************************************************************** +// RangeParameters::setrange +//***************************************************************************** +void RangeParameters::setRange(double range) +{ + m_range = range; +} + +//***************************************************************************** +// RangeParametersCovar::getType(() +//***************************************************************************** +ProjectionGeometryType RangeParametersCovar::getType() const +{ + return ProjectionGeometryType::RANGECOVAR; +} + +//***************************************************************************** +// RangeParametersCovar::RangeParametersCovar() +//***************************************************************************** +RangeParametersCovar::RangeParametersCovar() +{ + m_range = 0.0; + m_rangeVariance = 0.0; +} + +//***************************************************************************** +// RangeParametersCovar::RangeParametersCovar(double range, double rangeVar) +//***************************************************************************** +RangeParametersCovar::RangeParametersCovar(double range, double rangeVar) +{ + m_range = range; + m_rangeVariance = rangeVar; +} + +//***************************************************************************** +// RangeParametersCovar::getrange +//***************************************************************************** +double RangeParametersCovar::getRange() const +{ + return m_range; +} + +//***************************************************************************** +// RangeParametersCovar::getrangeVariance +//***************************************************************************** +double RangeParametersCovar::getRangeVariance() const +{ + return m_rangeVariance; +} + +//***************************************************************************** +// RangeParametersCovar::setrange +//***************************************************************************** +void RangeParametersCovar::setRange(double range) +{ + m_range = range; +} + +//***************************************************************************** +// RangeParametersCovar::setrangeVariance +//***************************************************************************** +void RangeParametersCovar::setRangeVariance(double rangeVar) +{ + m_rangeVariance = rangeVar; +} +//***************************************************************************** +// PlaneParameters::getType(() +//***************************************************************************** +ProjectionGeometryType PlaneParameters::getType() const +{ + return ProjectionGeometryType::PLANE; +} +//***************************************************************************** +// PlaneParameters::PlaneParameters() +//***************************************************************************** +PlaneParameters::PlaneParameters() +{ + m_point = ObjectSpaceCoordinate(); + m_normal = ObjectSpaceVector(); +} + +//***************************************************************************** +// PlaneParameters::PlaneParameters(const ObjectSpaceCoordinate& coord, const ObjectSpaceVector& normal) +//****************************************************************************** +PlaneParameters::PlaneParameters(const ObjectSpaceCoordinate& coord, const ObjectSpaceVector& normal) +{ + m_point = coord; + m_normal = normal; +} +//******************************************************************************* +// PlaneParameters::getPoint() +//******************************************************************************** +const ObjectSpaceCoordinate& PlaneParameters::getPoint() const +{ + return m_point; +} + +//******************************************************************************* +// PlaneParameters::getNormal() +//******************************************************************************** +const ObjectSpaceVector& PlaneParameters::getNormal() const +{ + return m_normal; +} + +//******************************************************************************* +// PlaneParameters::setPoint() +//******************************************************************************** +void PlaneParameters::setPoint(const ObjectSpaceCoordinate& pointArg) +{ + m_point = pointArg; // assignment operator usage +} + +//******************************************************************************* +// PlaneParameters::setNormal() +//******************************************************************************** +void PlaneParameters::setNormal(const ObjectSpaceVector& normalArg) +{ + m_normal = normalArg; // assignment operator usage +} + +//***************************************************************************** +// PlaneParametersCovar::getType(() +//***************************************************************************** +ProjectionGeometryType PlaneParametersCovar::getType() const +{ + return ProjectionGeometryType::PLANECOVAR; +} + +//******************************************************************************* +// PlaneParametersCovar::PlaneParametersCovar() +//******************************************************************************** +PlaneParametersCovar::PlaneParametersCovar() +{ + m_point = ObjectSpaceCoordinateCovar(); + m_normal = ObjectSpaceVectorCovar(); +} + +//***************************************************************************** +// PlaneParameters::PlaneParameters(const ObjectSpaceCoordinate& coord, const ObjectSpaceVector& normal) +//****************************************************************************** +PlaneParametersCovar::PlaneParametersCovar(const ObjectSpaceCoordinateCovar& coord, const ObjectSpaceVectorCovar& normal) +{ + m_point = coord; + m_normal = normal; +} + +//******************************************************************************* +// PlaneParametersCovar::getPoint() +//******************************************************************************** +const ObjectSpaceCoordinateCovar& PlaneParametersCovar::getPoint() const +{ + return m_point; +} + +//******************************************************************************* +// PlaneParametersCovar::getNormal() +//******************************************************************************** +const ObjectSpaceVectorCovar& PlaneParametersCovar::getNormal() const +{ + return m_normal; +} + +//******************************************************************************* +// PlaneParametersCovar::setPoint() +//******************************************************************************** +void PlaneParametersCovar::setPoint(const ObjectSpaceCoordinateCovar& pointArg) +{ + m_point = pointArg; // assignment operator usage +} + +//******************************************************************************* +// PlaneParametersCovar::setNormal() +//******************************************************************************** +void PlaneParametersCovar::setNormal(const ObjectSpaceVectorCovar& normalArg) +{ + m_normal = normalArg; // assignment operator usage +} + +} // namespace csm diff --git a/ProjectionParameters.h b/ProjectionParameters.h new file mode 100644 index 0000000..8dbe228 --- /dev/null +++ b/ProjectionParameters.h @@ -0,0 +1,274 @@ +//#################################################################### +// +// FILENAME: ProjectionParameters.h +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// Header for object space single image projection parameters. +// +// LIMITATIONS: None +// +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 31-March-2022 Eugene Rose CCB Change CSM 3.0.4 +// +// NOTES: +// +//##################################################################### + +#ifndef __PROJECTIONPARAMETERS_H +#define __PROJECTIONPARAMETERS_H + +#include "csm.h" +#include "ObjectSpace.h" +//> +// need ObjectSpace.h for ObjectSpaceCoordinate etc. +//< + +namespace csm +{ + +enum class ProjectionGeometryType +{ + RANGE, + PLANE, + RANGECOVAR, + PLANECOVAR, + UNSPECIFIED +}; +//> +// This enum class identifies the projection parameters type. +//< + +// ************************************************************ +// ProjectionParameters virtual base class +// ************************************************************ +class CSM_EXPORT_API ProjectionParameters +{ + +public: + virtual ~ProjectionParameters() {}; + //> + // virtual destructor provides something for base class destructors to call on. + //< + + virtual ProjectionGeometryType getType() const = 0; + //> + // returns the type enum parameter + //< +protected: + ProjectionParameters() {}; + //> + // the default constructor does nothing + //< + +}; + +// ************************************************************ +// ProjectionParametersCovar virtual base class +// ************************************************************ +class CSM_EXPORT_API ProjectionParametersCovar +{ + +public: + virtual ~ProjectionParametersCovar() {}; + //> + // virtual destructor provides something for base class destructors to call on. + //< + + virtual ProjectionGeometryType getType() const = 0; + //> + // returns the type enum parameter + //< +protected: + ProjectionParametersCovar() {}; + //> + // the default constructor does nothing + //< + +}; + +class CSM_EXPORT_API RangeParameters : public ProjectionParameters +{ +public: + RangeParameters(); + //> + // default constructor sets range to zero and also + // sets m_type to RANGE + //< + + RangeParameters(double range); + //> + // initializes with the given range in meters + //< + + ProjectionGeometryType getType() const; + //> + // get the geometry type (enum) + //< + + const double &getRange() const; + //> + // return the range value in meters + //< + + void setRange(double range); + //> + // set the range in an existing object + //< + +protected: + double m_range; +}; + +class CSM_EXPORT_API RangeParametersCovar : public ProjectionParametersCovar +{ +public: + RangeParametersCovar(); + //> + // default constructor sets range and range variance to zero and also + // sets m_type to RANGE + //< + + RangeParametersCovar(double range, double rangeVariance); + //> + // initializes with the give values in meters and meters-squared + //< + + ProjectionGeometryType getType() const; + //> + // get the geometry type (enum) + //< + + double getRange() const; + //> return the range value in meters + //< + + double getRangeVariance() const; + //> + // returns the range variance + //< + + void setRange(double range); + //> + // set the range in an existing object + //< + + void setRangeVariance(double rangeVar); + //> + // set the range variance in an existing object + //< + + +protected: + double m_range; + //> + // range value in meters + //< + double m_rangeVariance; + //> + // range variance in meters squared + //< +}; + +class CSM_EXPORT_API PlaneParameters : public ProjectionParameters +{ +public: + PlaneParameters(); + //> the default constructor will intialize the point and the vector to + // zero. + // Also sets m_type to PLANE + //< + + PlaneParameters(const ObjectSpaceCoordinate& coord, const ObjectSpaceVector& normal); + + //> this constructor will initialize the point and the normal with the give values. + //< + + ProjectionGeometryType getType() const; + //> + // get the geometry type (enum) + //< + + const ObjectSpaceCoordinate& getPoint() const; + //> read the point + //< + + const ObjectSpaceVector& getNormal() const; + //> read the normal + //< + + void setPoint(const ObjectSpaceCoordinate& pointArg); + //< + // set the point in an existing object + //> + + void setNormal(const ObjectSpaceVector& normalArg); + //< + // set the normal in an existing object + //< + +protected: + ObjectSpaceCoordinate m_point; + //> a point on the plane. + //< + ObjectSpaceVector m_normal; + //> + // normal to the plane + //< +}; + +class CSM_EXPORT_API PlaneParametersCovar : public ProjectionParametersCovar +{ +public: + PlaneParametersCovar(); + //> the default constructor will intialize the point and the vector to + // zero. Also the point and vector covariances to zero. + // Also sets m_type to PLANE + //< + + PlaneParametersCovar(const ObjectSpaceCoordinateCovar& coord, const ObjectSpaceVectorCovar& normal); + //> + // this constructor will initialize the point and the normal with the give values. + //< + + ProjectionGeometryType getType() const; + //> + // get the geometry type (enum) + //< + + const ObjectSpaceCoordinateCovar &getPoint() const; + //> + // read the point + //< + + const ObjectSpaceVectorCovar &getNormal() const; + //> + // read the normal + //< + + void setPoint(const ObjectSpaceCoordinateCovar& pointArg); + //< + // set the point in an existing object + //> + + void setNormal(const ObjectSpaceVectorCovar& normalArg); + //< + // set the normal in an existing object + //< +protected: + ObjectSpaceCoordinateCovar m_point; + //> a point on the plane. + //< + ObjectSpaceVectorCovar m_normal; + //> + // normal to the plane + //< +}; +} + +#endif // __PROJECTIONPARAMETERS_H diff --git a/WGS84ReferenceFrame.cpp b/WGS84ReferenceFrame.cpp new file mode 100644 index 0000000..8d3799c --- /dev/null +++ b/WGS84ReferenceFrame.cpp @@ -0,0 +1,59 @@ +//#################################################################### +// +// FILENAME: WGS84ReferenceFrame.cpp +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// Implementation for WGS84 reference frame realization and epoch. +// +// LIMITATIONS: None +// +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 31-December-2021 Eugene Rose CCB Change +// +// NOTES: +// As of writing this, these are the WGS84 realizations to date. +// WGS84 ORIGINAL 1984.0 +// G730 1994.0 +// G873 1997.0 +// G1150 2001.0 +// G1674 2005.0 +// G1762 2005.0 +// +//################################################################### +#define CSM_LIBRARY + +#include "csm.h" +#include "WGS84ReferenceFrame.h" + +namespace csm +{ +//**************************************************************************** +// WGS84ReferenceFrame::setDefinition() +//**************************************************************************** +void WGS84ReferenceFrame::setDefinition(const std::string &name, const float epoch) +{ + m_realization = RealizationDefinition(name, epoch); +} + +//**************************************************************************** +// WGS84ReferenceFrame::setDefinition() +//**************************************************************************** +void WGS84ReferenceFrame::setDefinition(const RealizationDefinition& rd) +{ + m_realization = rd; +} + +//**************************************************************************** +// WGS84ReferenceFrame::getDefinition() +//**************************************************************************** +csm::WGS84ReferenceFrame::RealizationDefinition WGS84ReferenceFrame::getDefinition() const +{ + return m_realization; +} +} diff --git a/WGS84ReferenceFrame.h b/WGS84ReferenceFrame.h new file mode 100644 index 0000000..1d695d8 --- /dev/null +++ b/WGS84ReferenceFrame.h @@ -0,0 +1,92 @@ +//#################################################################### +// +// FILENAME: WGS84ReferenceFrame.h +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// Header for WGS84 reference frame realization and epoch. +// +// LIMITATIONS: None +// +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 31-December-2021 Eugene Rose CCB Change +// +// NOTES: +// As of writing this, these are the WGS84 realizations to date. +// WGS84 ORIGINAL 1984.0 +// G730 1994.0 +// G873 1997.0 +// G1150 2001.0 +// G1674 2005.0 +// G1762 2005.0 +// +//################################################################### + +#ifndef __CSM_WGS84REFERENCEFRAME_H +#define __CSM_WGS84REFERENCEFRAME_H + +#include "csm.h" +#include + +#define WGS84_ORIGINAL "WGS84 ORIGINAL" +#define WGS84_G730 "G730" +#define WGS84_G873 "G873" +#define WGS84_G1150 "G1150" +#define WGS84_G1674 "G1674" +#define WGS84_G1762 "G1762" + +namespace csm +{ + +class CSM_EXPORT_API WGS84ReferenceFrame +{ +public: + + struct CSM_EXPORT_API RealizationDefinition + { + public: + RealizationDefinition() : m_name("WGS84_ORIGINAL"), m_epoch(1984.0) {}; + RealizationDefinition(const std::string &name, float epoch) : m_name(name), m_epoch(epoch) {}; + std::string m_name; + float m_epoch; + }; + //> Realizations are defined by a string name and a float epoch which is in terms of years since 0AD. + // The default realization is the original one from 1984.0 + //< + + WGS84ReferenceFrame() {}; + //> construct default realization + //< + + WGS84ReferenceFrame(const std::string &name, const float epoch) : m_realization(name,epoch) {}; + //> construct custom realization + //< + + void setDefinition(const std::string &name, const float epoch); + //> convenience to set the internal structure (it is public) + //< + + void setDefinition(const RealizationDefinition& rd); + //> convenience to set the internal structure (it is public) + //< + + RealizationDefinition getDefinition() const; + //> convenience to get the internal structure (it is public) + //< + +private: + RealizationDefinition m_realization; + //> the name and epoch of the realization are here + //< + +}; + +} // namespace csm + +#endif // __CSM_WGS84REFERENCEFRAME_H +