Skip to content

Commit

Permalink
Added functions and codes to make stitch code work
Browse files Browse the repository at this point in the history
  • Loading branch information
amandasd committed Sep 3, 2024
1 parent cc4f8c0 commit 188dc11
Show file tree
Hide file tree
Showing 7 changed files with 1,224 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_library(TELite SimpleGrid.cpp Variable.cpp kdtree.cpp SimpleGridUtilities.cpp Announce.cpp)
add_library(TELite SimpleGrid.cpp Variable.cpp kdtree.cpp SimpleGridUtilities.cpp Announce.cpp TimeObj.cpp)

file(GLOB_RECURSE FILES_MATCHING "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
install(FILES ${FILES_MATCHING}
Expand Down
51 changes: 48 additions & 3 deletions src/CoordTransforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
/// Removed some functions (StereographicProjectionInv,
/// StereographicProjection, GreatCircleDistanceXYZ_Deg,
/// GreatCircleDistanceXYZ_Rad, VecTransRLL2DtoXYZ_Rad,
/// XYZtoRLL_Rad, XYZtoRLL_Deg, RLLtoXYZ_Deg, RLLtoXYZ_Rad,
/// XYZtoRLL_Rad, XYZtoRLL_Deg, RLLtoXYZ_Deg,
/// GreatCircleDistanceFromChordLength_Rad,
/// ChordLengthFromGreatCircleDistance_Deg, LonRadToStandardRange,
/// LonDegToStandardRange, DegToRad)
/// LonRadToStandardRange, LonDegToStandardRange)

#ifndef _COORDTRANSFORMS_H_
#define _COORDTRANSFORMS_H_
Expand All @@ -33,6 +32,8 @@

#include "Exception.h"

static const double HighTolerance = 1.0e-10;

///////////////////////////////////////////////////////////////////////////////

/// <summary>
Expand All @@ -46,6 +47,50 @@ inline double RadToDeg(

///////////////////////////////////////////////////////////////////////////////

/// <summary>
/// Convert degrees to radians.
/// </summary>
inline double DegToRad(
double dDeg
) {
return (dDeg * M_PI / 180.0);
}

///////////////////////////////////////////////////////////////////////////////

/// <summary>
/// Calculate the chord length from the great circle distance (in degrees).
/// </summary>
inline double ChordLengthFromGreatCircleDistance_Deg(
double dGCDDeg
) {
return 2.0 * sin(0.5 * DegToRad(dGCDDeg));
}

///////////////////////////////////////////////////////////////////////////////

/// <summary>
/// Calculate 3D Cartesian coordinates from latitude and longitude,
/// in radians.
/// </summary>
inline void RLLtoXYZ_Rad(
double dLonRad,
double dLatRad,
double & dX,
double & dY,
double & dZ
) {
if (fabs(dLatRad) > 0.5 * M_PI + HighTolerance) {
_EXCEPTION1("Latitude out of range (%2.14f)", dLatRad);
}

dX = cos(dLonRad) * cos(dLatRad);
dY = sin(dLonRad) * cos(dLatRad);
dZ = sin(dLatRad);
}

///////////////////////////////////////////////////////////////////////////////

/// <summary>
/// Calculate an average longitude from two given longitudes (in radians).
/// </summary>
Expand Down
24 changes: 23 additions & 1 deletion src/STLStringHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/// Amanda Dufek
/// March 28, 2023
/// Removed some functions (ConcatenateStringVector, ParseVariableList,
/// RemoveWhitespaceInPlace, IsInteger, IsIntegerIndex, ToUpper, ToLower)
/// RemoveWhitespaceInPlace, IsInteger, ToUpper)

#ifndef _STLSTRINGHELPER_H_
#define _STLSTRINGHELPER_H_
Expand All @@ -39,6 +39,28 @@ STLStringHelper() { }

///////////////////////////////////////////////////////////////////////////////

inline static void ToLower(std::string &str) {
for(size_t i = 0; i < str.length(); i++) {
str[i] = tolower(str[i]);
}
}

///////////////////////////////////////////////////////////////////////////////

inline static bool IsIntegerIndex(const std::string &str) {
if (str.length() == 0) {
return false;
}
for(size_t i = 0; i < str.length(); i++) {
if ((str[i] < '0') || (str[i] > '9')) {
return false;
}
}
return true;
}

///////////////////////////////////////////////////////////////////////////////

inline static bool IsFloat(const std::string &str) {
bool fIsFloat = false;
bool fHasExponent = false;
Expand Down
Loading

0 comments on commit 188dc11

Please sign in to comment.