diff --git a/Modules/Core/Metadata/include/otbDimapMetadataHelper.h b/Modules/Core/Metadata/include/otbDimapMetadataHelper.h index 7317f8615b4debb5c4ad26af92dd7220f59a7b31..c71b8742854fbac8b65082adef49463e442b006e 100644 --- a/Modules/Core/Metadata/include/otbDimapMetadataHelper.h +++ b/Modules/Core/Metadata/include/otbDimapMetadataHelper.h @@ -24,6 +24,7 @@ #include "OTBMetadataExport.h" #include "otbMetadataSupplierInterface.h" #include "otbSpot5Metadata.h" +#include "otbDateTime.h" namespace otb @@ -226,16 +227,18 @@ private: } - double GetTime(std::string timeStr){ + double GetTime(const std::string& timeStr){ // Time stamps are in the format: "yyyy-mm-ddThh:mm:ss.ssssss" - int year, month, day, hour, minute; - double second; - sscanf(timeStr.c_str(), - "%4d-%2d-%2dT%2d:%2d:%9lf", - &year, &month, &day, - &hour, &minute, &second); - return (((((year-2002.0)*12.0 + month - 1.0)*365.0 + day - 1.0)*24.0 - + hour)*60.0 + minute)*60.0 + second; + const auto d = MetaData::ReadFormattedDate(timeStr); + return d.GetSecond() + 60.0 * ( + d.GetMinute() + 60.0 * ( // Total NB of minutes + d.GetHour() + 24.0 * ( // Total NB of hours + d.GetDay() - 1.0 + 365.25 * ( // Total NB of days (-1 as day is not over) + d.GetYear() - 2002.0 + ) + ) + ) + ); } DimapData m_Data; diff --git a/Modules/Core/Transform/include/otbBilinearProjection.h b/Modules/Core/Transform/include/otbBilinearProjection.h index 6e15273c842fe04ef5f0b6e5d8b075f962f2d9ac..ffd5127e21e2a3794438312f52fc83467a680d1a 100644 --- a/Modules/Core/Transform/include/otbBilinearProjection.h +++ b/Modules/Core/Transform/include/otbBilinearProjection.h @@ -71,7 +71,7 @@ public: * @return image point to world point at given height */ Point3DType lineSampleHeightToWorld(Point2DType lineSampPt, - const double& heightAboveEllipsoid) const; + double heightAboveEllipsoid) const; const std::vector<Point2DType>& getLineSamplePoints() const; diff --git a/Modules/Core/Transform/include/otbSpot5SensorModel.h b/Modules/Core/Transform/include/otbSpot5SensorModel.h index 7f239506329e2d6d9d2de90dfdf0330fbbf2aade..a6475ad85e64e3408003fff8884e68a4f9ea6ca8 100644 --- a/Modules/Core/Transform/include/otbSpot5SensorModel.h +++ b/Modules/Core/Transform/include/otbSpot5SensorModel.h @@ -105,7 +105,7 @@ public: * @param[in] offset double offset * @return world point (lat,lon,hgt) */ - Point3DType NearestIntersection(const Ephemeris& imRay, const double& offset) const; + Point3DType NearestIntersection(const Ephemeris& imRay, double offset) const; /** * @brief Compute world point intersected by image ray. @@ -145,7 +145,7 @@ public: * @param[in] time input time * @return 3D position */ - Point3DType GetPositionEcf(const double& time) const; + Point3DType GetPositionEcf(double time) const; /** * @brief Get the 3D velocity of the sensor at time (interpolation of velocity samples vector from metadata). @@ -153,7 +153,7 @@ public: * @param[in] time input time * @return 3D position */ - Point3DType GetVelocityEcf(const double& time) const; + Point3DType GetVelocityEcf(double time) const; /** * @brief Get look angles on X and Y axis of the sensor at line (interpolation of angles samples vector from metadata). @@ -170,7 +170,7 @@ public: * @param[in] time input time * @return 3D attitude */ - Point3DType GetAttitude(const double& time) const; + Point3DType GetAttitude(double time) const; /** * @brief Compute SatToOrb matrix with an input time. diff --git a/Modules/Core/Transform/src/otbBilinearProjection.cxx b/Modules/Core/Transform/src/otbBilinearProjection.cxx index 1cf8c9d621bc3c13c0ab646a107042616142d2f9..1e637f7c443f77e4874588bc176919aafc9b8557 100644 --- a/Modules/Core/Transform/src/otbBilinearProjection.cxx +++ b/Modules/Core/Transform/src/otbBilinearProjection.cxx @@ -85,7 +85,7 @@ BilinearProjection::Point3DType BilinearProjection::lineSampleToWorld(Point2DTyp BilinearProjection::Point3DType BilinearProjection::lineSampleHeightToWorld( Point2DType lineSampPt, - const double& heightAboveEllipsoid) const + double heightAboveEllipsoid) const { itk::Vector<double,2> lineSampMatrix; lineSampMatrix[0] = lineSampPt[0]; diff --git a/Modules/Core/Transform/src/otbSpot5SensorModel.cxx b/Modules/Core/Transform/src/otbSpot5SensorModel.cxx index 064c91efd148506fb1ddd9ff27d8ace13d81e5ef..f9a56502cafe62dd116d9cbd23f54153f443fd6e 100644 --- a/Modules/Core/Transform/src/otbSpot5SensorModel.cxx +++ b/Modules/Core/Transform/src/otbSpot5SensorModel.cxx @@ -334,7 +334,7 @@ itk::Point<double, 3> Spot5SensorModel::GetLagrangeInterpolation( } -itk::Point<double, 3> Spot5SensorModel::GetPositionEcf(const double& time) const +itk::Point<double, 3> Spot5SensorModel::GetPositionEcf(double time) const { if((m_Spot5Param.EcefPosSamples.size() < 8)|| (m_Spot5Param.EcefTimeSamples.size() < 8)) @@ -348,7 +348,7 @@ itk::Point<double, 3> Spot5SensorModel::GetPositionEcf(const double& time) cons } -itk::Point<double, 3> Spot5SensorModel::GetVelocityEcf(const double& time) const +itk::Point<double, 3> Spot5SensorModel::GetVelocityEcf(double time) const { if((m_Spot5Param.EcefVelSamples.size() < 8)|| (m_Spot5Param.EcefTimeSamples.size() < 8)) @@ -362,7 +362,7 @@ itk::Point<double, 3> Spot5SensorModel::GetVelocityEcf(const double& time) cons } void Spot5SensorModel::GetPixelLookAngleXY(unsigned int line, - double& psiX, double& psiY) const + double& psiX, double& psiY) const { if (line >= m_Spot5Param.PixelLookAngleX.size()) { @@ -377,12 +377,12 @@ void Spot5SensorModel::GetPixelLookAngleXY(unsigned int line, } -itk::Point<double, 3> Spot5SensorModel::GetAttitude(const double& time) const +itk::Point<double, 3> Spot5SensorModel::GetAttitude(double time) const { return GetBilinearInterpolation(time, m_Spot5Param.AttitudesSamples, m_Spot5Param.AttitudesSamplesTimes); } -itk::Point<double, 3> Spot5SensorModel::NearestIntersection(const Ephemeris& imRay, const double& offset) const +itk::Point<double, 3> Spot5SensorModel::NearestIntersection(const Ephemeris& imRay, double offset) const { // WGS 84 parameters conversion double wgsA = 6378137.000;