Unverified Commit b4313de4 authored by Kristin's avatar Kristin Committed by GitHub
Browse files

Updated to use Google style for formatting (#307)

* Results of running clang-format using Google style on usgscsm code

* Add linted tests
parent dedf7a25
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
#ifndef Distortion_h
#define Distortion_h

#include <vector>
#include <math.h>
#include <tuple>
#include <iostream>
#include <tuple>
#include <vector>

enum DistortionType {
  RADIAL,
  TRANSVERSE,
  KAGUYALISM,
  DAWNFC,
  LROLROCNAC
};

enum DistortionType { RADIAL, TRANSVERSE, KAGUYALISM, DAWNFC, LROLROCNAC };

// Transverse Distortion
void distortionJacobian(double x, double y, double *jacobian,
@@ -30,5 +23,6 @@ void removeDistortion(double dx, double dy, double &ux, double &uy,
void applyDistortion(double ux, double uy, double &dx, double &dy,
                     const std::vector<double> opticalDistCoeffs,
                     DistortionType distortionType,
                     const double desiredPrecision = 1.0E-6, const double tolerance = 1.0E-6);
                     const double desiredPrecision = 1.0E-6,
                     const double tolerance = 1.0E-6);
#endif
+377 −375
Original line number Diff line number Diff line
@@ -2,19 +2,19 @@
#ifndef UsgsAstroFrameSensorModel_h
#define UsgsAstroFrameSensorModel_h

#include <SettableEllipsoid.h>
#include <cmath>
#include <iostream>
#include <vector>
#include "RasterGM.h"
#include <SettableEllipsoid.h>
#include "CorrelationModel.h"
#include "Distortion.h"
#include "RasterGM.h"
#include "Utilities.h"

#include "spdlog/spdlog.h"


class UsgsAstroFrameSensorModel : public csm::RasterGM, virtual public csm::SettableEllipsoid {
class UsgsAstroFrameSensorModel : public csm::RasterGM,
                                  virtual public csm::SettableEllipsoid {
  // UsgsAstroFramePlugin needs to access private members
  friend class UsgsAstroFramePlugin;

@@ -22,58 +22,58 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM, virtual public csm::Sett
  UsgsAstroFrameSensorModel();
  ~UsgsAstroFrameSensorModel();


    bool isValidModelState(const std::string& stringState, csm::WarningList *warnings);
  bool isValidModelState(const std::string &stringState,
                         csm::WarningList *warnings);
  bool isValidIsd(const std::string &stringIsd, csm::WarningList *warnings);

    virtual csm::ImageCoord groundToImage(const csm::EcefCoord &groundPt,
                                     double desiredPrecision=0.001,
  virtual csm::ImageCoord groundToImage(
      const csm::EcefCoord &groundPt, double desiredPrecision = 0.001,
      double *achievedPrecision = NULL,
      csm::WarningList *warnings = NULL) const;


    std::string constructStateFromIsd(const std::string& jsonIsd, csm::WarningList *warnings);
  std::string constructStateFromIsd(const std::string &jsonIsd,
                                    csm::WarningList *warnings);
  void reset();

    virtual csm::ImageCoordCovar groundToImage(const csm::EcefCoordCovar &groundPt,
                                          double desiredPrecision=0.001,
  virtual csm::ImageCoordCovar groundToImage(
      const csm::EcefCoordCovar &groundPt, double desiredPrecision = 0.001,
      double *achievedPrecision = NULL,
      csm::WarningList *warnings = NULL) const;

    virtual csm::ImageCoord groundToImage(const csm::EcefCoord& ground_pt,
       const std::vector<double>& adjustments,
       double                     desired_precision=0.001,
       double*                    achieved_precision=NULL,
  virtual csm::ImageCoord groundToImage(
      const csm::EcefCoord &ground_pt, const std::vector<double> &adjustments,
      double desired_precision = 0.001, double *achieved_precision = NULL,
      csm::WarningList *warnings = NULL) const;

  /**
    * This function determines if a sample, line intersects the target body and if so, where
    * this intersection occurs in body-fixed coordinates.
   * This function determines if a sample, line intersects the target body and
   * if so, where this intersection occurs in body-fixed coordinates.
   *
   * @param sample Sample of the input image.
   * @param line Line of the input image.
   * @param height ???
   *
    * @return @b vector<double> Returns the body-fixed X,Y,Z coordinates of the intersection.
    *                           If no intersection, returns a 3-element vector of 0's.
   * @return @b vector<double> Returns the body-fixed X,Y,Z coordinates of the
   * intersection. If no intersection, returns a 3-element vector of 0's.
   */
    virtual csm::EcefCoord imageToGround(const csm::ImageCoord &imagePt, double height = 0.0,
                                    double desiredPrecision=0.001, double *achievedPrecision=NULL,
  virtual csm::EcefCoord imageToGround(const csm::ImageCoord &imagePt,
                                       double height = 0.0,
                                       double desiredPrecision = 0.001,
                                       double *achievedPrecision = NULL,
                                       csm::WarningList *warnings = NULL) const;

    virtual csm::EcefCoordCovar imageToGround(const csm::ImageCoordCovar &imagePt, double height,
                                           double heightVariance, double desiredPrecision=0.001,
                                           double *achievedPrecision=NULL,
  virtual csm::EcefCoordCovar imageToGround(
      const csm::ImageCoordCovar &imagePt, double height, double heightVariance,
      double desiredPrecision = 0.001, double *achievedPrecision = NULL,
      csm::WarningList *warnings = NULL) const;

    virtual csm::EcefLocus imageToProximateImagingLocus(const csm::ImageCoord &imagePt,
                                                      const csm::EcefCoord &groundPt,
                                                      double desiredPrecision=0.001,
                                                      double *achievedPrecision=NULL,
  virtual csm::EcefLocus imageToProximateImagingLocus(
      const csm::ImageCoord &imagePt, const csm::EcefCoord &groundPt,
      double desiredPrecision = 0.001, double *achievedPrecision = NULL,
      csm::WarningList *warnings = NULL) const;

    virtual csm::EcefLocus imageToRemoteImagingLocus(const csm::ImageCoord &imagePt,
                                                   double desiredPrecision=0.001,
  virtual csm::EcefLocus imageToRemoteImagingLocus(
      const csm::ImageCoord &imagePt, double desiredPrecision = 0.001,
      double *achievedPrecision = NULL,
      csm::WarningList *warnings = NULL) const;

@@ -81,19 +81,22 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM, virtual public csm::Sett

  virtual csm::ImageVector getImageSize() const;

    virtual std::pair<csm::ImageCoord, csm::ImageCoord> getValidImageRange() const;
  virtual std::pair<csm::ImageCoord, csm::ImageCoord> getValidImageRange()
      const;

  virtual std::pair<double, double> getValidHeightRange() const;

  /**
     * Calculates the illumination vector (body-fixed, meters) from the sun to the given ground
     * point.
   * Calculates the illumination vector (body-fixed, meters) from the sun to the
   * given ground point.
   *
   * @param groundPt The ground point to find the illumination vector to.
   *
     * @return @b csm::EcefVector Returns the illumination vector from the sun to the ground point.
   * @return @b csm::EcefVector Returns the illumination vector from the sun to
   * the ground point.
   */
    virtual csm::EcefVector getIlluminationDirection(const csm::EcefCoord &groundPt) const;
  virtual csm::EcefVector getIlluminationDirection(
      const csm::EcefCoord &groundPt) const;

  virtual double getImageTime(const csm::ImageCoord &imagePt) const;

@@ -106,12 +109,14 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM, virtual public csm::Sett
   *
   * @throw csm::Error::BOUNDS "Image coordinate () out of bounds."
   */
    virtual csm::EcefCoord getSensorPosition(const csm::ImageCoord &imagePt) const;
  virtual csm::EcefCoord getSensorPosition(
      const csm::ImageCoord &imagePt) const;

  virtual csm::EcefCoord getSensorPosition(double time) const;

  /**
     * Determines the velocity of the sensor for the given image coordinate (in body-fixed frame).
   * Determines the velocity of the sensor for the given image coordinate (in
   * body-fixed frame).
   *
   * @param imagePt Image coordinate to find the sensor position for.
   *
@@ -120,42 +125,39 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM, virtual public csm::Sett
   * @throw csm::Error::BOUNDS "Image coordinate () out of bounds."
   */

    virtual csm::EcefVector getSensorVelocity(const csm::ImageCoord &imagePt) const;
  virtual csm::EcefVector getSensorVelocity(
      const csm::ImageCoord &imagePt) const;

  virtual csm::EcefVector getSensorVelocity(double time) const;

    virtual csm::RasterGM::SensorPartials computeSensorPartials(int index,
                                                                const csm::EcefCoord &groundPt,
                                                                double desiredPrecision=0.001,
                                                                double *achievedPrecision=NULL,
  virtual csm::RasterGM::SensorPartials computeSensorPartials(
      int index, const csm::EcefCoord &groundPt,
      double desiredPrecision = 0.001, double *achievedPrecision = NULL,
      csm::WarningList *warnings = NULL) const;

    virtual csm::RasterGM::SensorPartials computeSensorPartials(int index,
                                                                const csm::ImageCoord &imagePt,
                                                                const csm::EcefCoord &groundPt,
                                                                double desiredPrecision=0.001,
                                                                double *achievedPrecision=NULL,
  virtual csm::RasterGM::SensorPartials computeSensorPartials(
      int index, const csm::ImageCoord &imagePt, const csm::EcefCoord &groundPt,
      double desiredPrecision = 0.001, double *achievedPrecision = NULL,
      csm::WarningList *warnings = NULL) const;

    virtual std::vector<csm::RasterGM::SensorPartials> computeAllSensorPartials (const csm::EcefCoord& groundPt,
                                                                csm::param::Set pSet = csm::param::VALID,
                                                                double desiredPrecision = 0.001,
                                                                double *achievedPrecision = NULL,
  virtual std::vector<csm::RasterGM::SensorPartials> computeAllSensorPartials(
      const csm::EcefCoord &groundPt, csm::param::Set pSet = csm::param::VALID,
      double desiredPrecision = 0.001, double *achievedPrecision = NULL,
      csm::WarningList *warnings = NULL) const;

    virtual std::vector<csm::RasterGM::SensorPartials> computeAllSensorPartials (const csm::ImageCoord& imagePt,
                                                                const csm::EcefCoord& groundPt,
                                                                csm::param::Set pSet = csm::param::VALID,
                                                                double desiredPrecision = 0.001,
  virtual std::vector<csm::RasterGM::SensorPartials> computeAllSensorPartials(
      const csm::ImageCoord &imagePt, const csm::EcefCoord &groundPt,
      csm::param::Set pSet = csm::param::VALID, double desiredPrecision = 0.001,
      double *achievedPrecision = NULL,
      csm::WarningList *warnings = NULL) const;

    virtual std::vector<double> computeGroundPartials(const csm::EcefCoord &groundPt) const;
  virtual std::vector<double> computeGroundPartials(
      const csm::EcefCoord &groundPt) const;

  virtual const csm::CorrelationModel &getCorrelationModel() const;

    virtual std::vector<double> getUnmodeledCrossCovariance(const csm::ImageCoord &pt1,
                                                            const csm::ImageCoord &pt2) const;
  virtual std::vector<double> getUnmodeledCrossCovariance(
      const csm::ImageCoord &pt1, const csm::ImageCoord &pt2) const;

  // IMPLEMENT MODEL PURE VIRTUALS
  //---
@@ -309,10 +311,12 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM, virtual public csm::Sett
  virtual csm::param::Type getParameterType(int index) const;
  virtual void setParameterType(int index, csm::param::Type pType);
  virtual double getParameterCovariance(int index1, int index2) const;
    virtual void setParameterCovariance(int index1, int index2, double covariance);
  virtual void setParameterCovariance(int index1, int index2,
                                      double covariance);
  virtual int getNumGeometricCorrectionSwitches() const;
  virtual std::string getGeometricCorrectionName(int index) const;
    virtual void setGeometricCorrectionSwitch(int index, bool value, csm::param::Type pType);
  virtual void setGeometricCorrectionSwitch(int index, bool value,
                                            csm::param::Type pType);
  virtual bool getGeometricCorrectionSwitch(int index) const;
  virtual std::vector<double> getCrossCovarianceMatrix(
      const GeometricModel &comparisonModel,
@@ -322,13 +326,12 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM, virtual public csm::Sett
  virtual void setLogger(std::string logName);
  double getValue(int index, const std::vector<double> &adjustments) const;
  void calcRotationMatrix(double m[3][3]) const;
    void calcRotationMatrix(double m[3][3], const std::vector<double> &adjustments) const;
  void calcRotationMatrix(double m[3][3],
                          const std::vector<double> &adjustments) const;

    void losEllipsoidIntersect (double height,double xc,
                                double yc, double zc,
                                double xl, double yl,
                                double zl,
                                double& x,double& y, double&  z) const;
  void losEllipsoidIntersect(double height, double xc, double yc, double zc,
                             double xl, double yl, double zl, double &x,
                             double &y, double &z) const;

  static const std::string _SENSOR_MODEL_NAME;

@@ -388,7 +391,6 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM, virtual public csm::Sett
  static const std::string _STATE_KEYWORD[];

  csm::NoCorrelationModel _no_corr_model;

};

#endif
+948 −1013

File changed.

Preview size limit exceeded, changes collapsed.

+44 −45
Original line number Diff line number Diff line
#ifndef UsgsAstroPlugin_h
#define UsgsAstroPlugin_h


#include <string>

#include <Plugin.h>
#include <Version.h>

#include <nlohmann/json.hpp>
#include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/spdlog.h"

class UsgsAstroPlugin : public csm::Plugin {

 public:
  UsgsAstroPlugin();
  ~UsgsAstroPlugin();
@@ -26,27 +24,28 @@ class UsgsAstroPlugin : public csm::Plugin {
  virtual std::string getModelName(size_t modelIndex) const;
  virtual std::string getModelFamily(size_t modelIndex) const;
  virtual csm::Version getModelVersion(const std::string &modelName) const;
    virtual bool canModelBeConstructedFromState(const std::string &modelName,
                                                const std::string &modelState,
                                                csm::WarningList *warnings = NULL) const;
    virtual bool canModelBeConstructedFromISD(const csm::Isd &imageSupportData,
                                              const std::string &modelName,
                                              csm::WarningList *warnings = NULL) const;
    virtual csm::Model *constructModelFromState(const std::string &modelState,
  virtual bool canModelBeConstructedFromState(
      const std::string &modelName, const std::string &modelState,
      csm::WarningList *warnings = NULL) const;
    virtual csm::Model *constructModelFromISD(const csm::Isd &imageSupportData,
                                              const std::string &modelName,
  virtual bool canModelBeConstructedFromISD(
      const csm::Isd &imageSupportData, const std::string &modelName,
      csm::WarningList *warnings = NULL) const;
    virtual std::string getModelNameFromModelState(const std::string &modelState,
  virtual csm::Model *constructModelFromState(
      const std::string &modelState, csm::WarningList *warnings = NULL) const;
  virtual csm::Model *constructModelFromISD(
      const csm::Isd &imageSupportData, const std::string &modelName,
      csm::WarningList *warnings = NULL) const;
    virtual bool canISDBeConvertedToModelState(const csm::Isd &imageSupportData,
                                               const std::string &modelName,
  virtual std::string getModelNameFromModelState(
      const std::string &modelState, csm::WarningList *warnings = NULL) const;
  virtual bool canISDBeConvertedToModelState(
      const csm::Isd &imageSupportData, const std::string &modelName,
      csm::WarningList *warnings = NULL) const;
    virtual std::string convertISDToModelState(const csm::Isd &imageSupportData,
                                               const std::string &modelName,
  virtual std::string convertISDToModelState(
      const csm::Isd &imageSupportData, const std::string &modelName,
      csm::WarningList *warnings = NULL) const;

    std::string loadImageSupportData(const csm::Isd &imageSupportDataOriginal) const;
  std::string loadImageSupportData(
      const csm::Isd &imageSupportDataOriginal) const;

  // TODO when implementing, add any other necessary members.

+183 −198

File changed.

Preview size limit exceeded, changes collapsed.

Loading