From 7048d939f519e0fb291add7ff584104e70c76c49 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 5 Jul 2017 13:42:18 -0700 Subject: [PATCH 01/25] Added an OSX makefile --- Makefile.mac | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Makefile.mac diff --git a/Makefile.mac b/Makefile.mac new file mode 100644 index 0000000..956def2 --- /dev/null +++ b/Makefile.mac @@ -0,0 +1,8 @@ +include Makefile + +CC=clang++ +#CXXFLAGS=-stdlib=libstdc++ +#CPPFAGS=-stdlib=libstdc++ +COPTS=-fPIC -O2 -m64 -Wall -stdlib=libc++ -std=c++11 +LDOPTS=-shared -Wl,-install_name,$(LIBRARY) +INSTDIR=$(PWD)/mac From 3f9c903de283f1f7221bbc20d8dc90ea55ac5a66 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 5 Jul 2017 20:25:04 -0700 Subject: [PATCH 02/25] rpath working on OS X --- Makefile.mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.mac b/Makefile.mac index 956def2..318776e 100644 --- a/Makefile.mac +++ b/Makefile.mac @@ -4,5 +4,5 @@ CC=clang++ #CXXFLAGS=-stdlib=libstdc++ #CPPFAGS=-stdlib=libstdc++ COPTS=-fPIC -O2 -m64 -Wall -stdlib=libc++ -std=c++11 -LDOPTS=-shared -Wl,-install_name,$(LIBRARY) +LDOPTS=-dynamiclib -Wl,-install_name,@rpath/$(LIBRARY) INSTDIR=$(PWD)/mac From bd8d8c6844fb4fc0f4fd692c8a7f6ca49bc89575 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 2 Aug 2017 15:22:50 -0700 Subject: [PATCH 03/25] Overriding .so on lib ext --- Makefile.mac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.mac b/Makefile.mac index 318776e..c2ba658 100644 --- a/Makefile.mac +++ b/Makefile.mac @@ -3,6 +3,9 @@ include Makefile CC=clang++ #CXXFLAGS=-stdlib=libstdc++ #CPPFAGS=-stdlib=libstdc++ + +LIBRARY=$(LIBNAME).dylib.$(LIBVERSION) + COPTS=-fPIC -O2 -m64 -Wall -stdlib=libc++ -std=c++11 LDOPTS=-dynamiclib -Wl,-install_name,@rpath/$(LIBRARY) INSTDIR=$(PWD)/mac From 71aa6e790e1dd765445d004cdf30f872911842e0 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 2 Aug 2017 20:07:07 -0700 Subject: [PATCH 04/25] Fixes OSX build via conda --- Makefile.mac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.mac b/Makefile.mac index c2ba658..9db406f 100644 --- a/Makefile.mac +++ b/Makefile.mac @@ -1,11 +1,12 @@ include Makefile CC=clang++ -#CXXFLAGS=-stdlib=libstdc++ -#CPPFAGS=-stdlib=libstdc++ LIBRARY=$(LIBNAME).dylib.$(LIBVERSION) COPTS=-fPIC -O2 -m64 -Wall -stdlib=libc++ -std=c++11 LDOPTS=-dynamiclib -Wl,-install_name,@rpath/$(LIBRARY) INSTDIR=$(PWD)/mac + +install:: + $(RM) $(INSTDIR)/lib/$(LIBNAME).so && $(LN) $(LIBRARY) $(INSTDIR)/lib/$(LIBNAME).dylib From f1dfff0b0dd1d8986428dd455573b580edbcb656 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 8 Nov 2017 09:55:18 -0700 Subject: [PATCH 05/25] Updates to makefile --- Makefile.win32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.win32 b/Makefile.win32 index 7277704..e5ba44b 100644 --- a/Makefile.win32 +++ b/Makefile.win32 @@ -28,6 +28,6 @@ $(LIBRARY): $(OBJS) install:: $(RM) $(INSTDIR)/lib/$(LIBNAME).so $(CP) $(LIBRARY:%.dll=%.lib) $(INSTDIR)/lib - + $(CP) $(HEADERS) $(INSTDIR)/include/csm clean:: $(RM) $(LIBRARY).manifest $(LIBRARY:%.dll=%.ldf) $(LIBRARY:%.dll=%.lib) $(LIBRARY:%.dll=%.exp) From 0a172b5c21227647d6f4cb26b5a4d673aeb92825 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 8 Nov 2017 12:57:30 -0700 Subject: [PATCH 06/25] Updates to the mac makefile --- Makefile.mac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile.mac b/Makefile.mac index 9db406f..c06b3cf 100644 --- a/Makefile.mac +++ b/Makefile.mac @@ -4,9 +4,12 @@ CC=clang++ LIBRARY=$(LIBNAME).dylib.$(LIBVERSION) -COPTS=-fPIC -O2 -m64 -Wall -stdlib=libc++ -std=c++11 +COPTS=-fPIC -O2 -m64 -Wall -stdlib=libc++ -std=c++11 LDOPTS=-dynamiclib -Wl,-install_name,@rpath/$(LIBRARY) INSTDIR=$(PWD)/mac +clean:: + $(RM) $(OBJS) $(LIBRARY) *~ + install:: $(RM) $(INSTDIR)/lib/$(LIBNAME).so && $(LN) $(LIBRARY) $(INSTDIR)/lib/$(LIBNAME).dylib From 0305547e1d93927ccfb0361b2d031a08c8853c01 Mon Sep 17 00:00:00 2001 From: jay Date: Fri, 1 Dec 2017 09:49:02 -0700 Subject: [PATCH 07/25] Updates to CSM 3.0.3 --- .gitignore | 2 + Ellipsoid.cpp | 222 +++++++++++++++++++++++----------------------- Ellipsoid.h | 21 ++--- Makefile | 1 - ModelIdentifier.h | 3 +- csmPointCloud.h | 24 ++++- 6 files changed, 148 insertions(+), 125 deletions(-) diff --git a/.gitignore b/.gitignore index 179fec7..53e827a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ solaris64_stlport/ solaris86/ win32/ *~ +*.o +*.so* diff --git a/Ellipsoid.cpp b/Ellipsoid.cpp index 45819c7..fc23553 100644 --- a/Ellipsoid.cpp +++ b/Ellipsoid.cpp @@ -1,111 +1,111 @@ -//############################################################################# -// -// FILENAME: Ellipsoid.cpp -// -// CLASSIFICATION: Unclassified -// -// DESCRIPTION: -// -// This file provides implementation for methods declared in the -// Ellipsoid class. -// -// SOFTWARE HISTORY: -// Date Author Comment -// ----------- ------ ------- -// 06-Aug-2016 Krinsky Initial Coding -// 03-Sep-2021 SCM Use cmath. -// -//############################################################################# - -#ifndef CSM_LIBRARY -#define CSM_LIBRARY -#endif - -#include "Ellipsoid.h" -#include - -namespace csm -{ - //***************************************************************************** - // Ellipsoid::Ellipsoid() - //***************************************************************************** - Ellipsoid::Ellipsoid() - { - setEllipsoid(CSM_WGS84_SEMI_MAJOR_AXIS, CSM_WGS84_SEMI_MINOR_AXIS); - } - - //************************************************************************** - // Ellipsoid::Ellipsoid() - //************************************************************************** - Ellipsoid::Ellipsoid( - double semiMajorRadius, - double semiMinorRadius) - { - setEllipsoid( semiMajorRadius, semiMinorRadius ); - } - - //************************************************************************** - // Ellipsoid::~Ellipsoid() - //************************************************************************** - Ellipsoid::~Ellipsoid() {} - - double Ellipsoid::calculateHeight( - const csm::EcefCoord& geocentric, - double desiredPrecision, - double* achievedPrecision, - csm::WarningList* warnings) const - { - const int MKTR = 10; - double eccSquare = 1.0 - mSemiMinorAxis * mSemiMinorAxis / mSemiMajorAxis / mSemiMajorAxis; - double ep2 = 1.0 - eccSquare; - double d2 = geocentric.x * geocentric.x + geocentric.y * geocentric.y; - double d = sqrt(d2); - double h = 0.0; - int ktr = 0; - double hPrev, r; - - // Suited for points near equator - if (d >= geocentric.z) - { - double tt, zz, n; - double tanPhi = geocentric.z / d; - do - { - hPrev = h; - tt = tanPhi * tanPhi; - r = mSemiMajorAxis / sqrt(1.0 + ep2 * tt); - zz = geocentric.z + r * eccSquare * tanPhi; - n = r * sqrt(1.0 + tt); - h = sqrt(d2 + zz * zz) - n; - tanPhi = zz / d; - ktr++; - } while (MKTR > ktr && fabs(h - hPrev) > desiredPrecision); - } - - // Suited for points near the poles - else - { - double cc, dd, nn; - double cotPhi = d / geocentric.z; - do - { - hPrev = h; - cc = cotPhi * cotPhi; - r = mSemiMajorAxis / sqrt(ep2 + cc); - dd = d - r * eccSquare * cotPhi; - nn = r * sqrt(1.0 + cc) * ep2; - h = sqrt(dd * dd + geocentric.z * geocentric.z) - nn; - cotPhi = dd / geocentric.z; - ktr++; - } while (MKTR > ktr && fabs(h - hPrev) > desiredPrecision); - } - - if (achievedPrecision) - { - *achievedPrecision = fabs(h - hPrev); - } - - return h; - } - -} // namespace csm +//############################################################################# +// +// FILENAME: Ellipsoid.cpp +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// This file provides implementation for methods declared in the +// Ellipsoid class. +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 06-Aug-2016 Krinsky Initial Coding +// 03-Sep-2021 SCM Use cmath. +// +//############################################################################# + +#ifndef CSM_LIBRARY +#define CSM_LIBRARY +#endif + +#include "Ellipsoid.h" +#include + +namespace csm +{ + //***************************************************************************** + // Ellipsoid::Ellipsoid() + //***************************************************************************** + Ellipsoid::Ellipsoid() + { + setEllipsoid(CSM_WGS84_SEMI_MAJOR_AXIS, CSM_WGS84_SEMI_MINOR_AXIS); + } + + //************************************************************************** + // Ellipsoid::Ellipsoid() + //************************************************************************** + Ellipsoid::Ellipsoid( + double semiMajorRadius, + double semiMinorRadius) + { + setEllipsoid( semiMajorRadius, semiMinorRadius ); + } + + //************************************************************************** + // Ellipsoid::~Ellipsoid() + //************************************************************************** + Ellipsoid::~Ellipsoid() {} + + double Ellipsoid::calculateHeight( + const csm::EcefCoord& geocentric, + double desiredPrecision, + double* achievedPrecision, + csm::WarningList* warnings) const + { + const int MKTR = 10; + double eccSquare = 1.0 - mSemiMinorAxis * mSemiMinorAxis / mSemiMajorAxis / mSemiMajorAxis; + double ep2 = 1.0 - eccSquare; + double d2 = geocentric.x * geocentric.x + geocentric.y * geocentric.y; + double d = sqrt(d2); + double h = 0.0; + int ktr = 0; + double hPrev, r; + + // Suited for points near equator + if (d >= geocentric.z) + { + double tt, zz, n; + double tanPhi = geocentric.z / d; + do + { + hPrev = h; + tt = tanPhi * tanPhi; + r = mSemiMajorAxis / sqrt(1.0 + ep2 * tt); + zz = geocentric.z + r * eccSquare * tanPhi; + n = r * sqrt(1.0 + tt); + h = sqrt(d2 + zz * zz) - n; + tanPhi = zz / d; + ktr++; + } while (MKTR > ktr && fabs(h - hPrev) > desiredPrecision); + } + + // Suited for points near the poles + else + { + double cc, dd, nn; + double cotPhi = d / geocentric.z; + do + { + hPrev = h; + cc = cotPhi * cotPhi; + r = mSemiMajorAxis / sqrt(ep2 + cc); + dd = d - r * eccSquare * cotPhi; + nn = r * sqrt(1.0 + cc) * ep2; + h = sqrt(dd * dd + geocentric.z * geocentric.z) - nn; + cotPhi = dd / geocentric.z; + ktr++; + } while (MKTR > ktr && fabs(h - hPrev) > desiredPrecision); + } + + if (achievedPrecision) + { + *achievedPrecision = fabs(h - hPrev); + } + + return h; + } + +} // namespace csm diff --git a/Ellipsoid.h b/Ellipsoid.h index 8293ddc..dc13556 100644 --- a/Ellipsoid.h +++ b/Ellipsoid.h @@ -39,26 +39,26 @@ #define CSM_WGS84_SEMI_MAJOR_AXIS 6378137.000 #define CSM_WGS84_SEMI_MINOR_AXIS 6356752.3142451794975639665996337 -namespace csm +namespace csm { class CSM_EXPORT_API Ellipsoid { public: - + Ellipsoid(); - //> This constructor defaults to the WGS-84 ellipsoid. - //< + //> This constructor defaults to the WGS-84 ellipsoid. + //< Ellipsoid( double semiMajorRadius, double semiMinorRadius); - //> This constructor sets the ellipsoid to that specified. - //< + //> This constructor sets the ellipsoid to that specified. + //< virtual ~Ellipsoid(); - //> Virtual destructor allows for inheritance. - //< + //> Virtual destructor allows for inheritance. + //< virtual double getSemiMajorRadius() const { @@ -80,7 +80,7 @@ namespace csm const csm::EcefCoord& geocentric, double desiredPrecision = 0.0001, double* achievedPrecision = NULL, - csm::WarningList* warnings = NULL ) const; + csm::WarningList* warnings = NULL) const; //> This method determines the height above the planetary // ellipsoid of the input ground point. Note that while // the input point uses an ECEF coordinate, the point is @@ -97,7 +97,7 @@ namespace csm //> This method sets the semi-major and semi-minor // radii describing the planetary ellipsoid. //< - + protected: double mSemiMajorAxis; @@ -107,3 +107,4 @@ namespace csm } // namespace csm #endif + diff --git a/Makefile b/Makefile index a4a7118..444ef1e 100644 --- a/Makefile +++ b/Makefile @@ -58,4 +58,3 @@ doxygen:: echo "INPUT_FILTER = $(DOXYGEN_FILTER)" >> $(DOXYFILE) rm -rf $(DOXYGEN_OUT) cd $(dir $(DOXYFILE)) && doxygen - diff --git a/ModelIdentifier.h b/ModelIdentifier.h index b32790c..4bf5615 100644 --- a/ModelIdentifier.h +++ b/ModelIdentifier.h @@ -227,7 +227,7 @@ class CSM_EXPORT_API RangeList // of type INT_TYPE //< bool contains(double argValue) const; - //> This method determines if the specified integer is in the current + //> This method determines if the specified double is in the current // range, which will only be true if the current data type is // of type DOUBLE_TYPE //< @@ -528,3 +528,4 @@ class CSM_EXPORT_API MIDescription } // namespace csm #endif + diff --git a/csmPointCloud.h b/csmPointCloud.h index a13544e..92358c8 100644 --- a/csmPointCloud.h +++ b/csmPointCloud.h @@ -27,11 +27,31 @@ #ifndef __CSM_CSM_POINT_CLOUD_H #define __CSM_CSM_POINT_CLOUD_H +#include #include + +// This include ensures that CURRENT_CSM_VERSION below isn't overwritten by +// csm.h. #include "csm.h" -namespace csm -{ +#ifdef _WIN32 +# ifdef CSM_POINT_CLOUD_LIBRARY +# define CSM_POINT_CLOUD_EXPORT_API __declspec(dllexport) +# else +# define CSM_POINT_CLOUD_EXPORT_API __declspec(dllimport) +# endif +#elif LINUX_BUILD +# define CSM_POINT_CLOUD_EXPORT_API __attribute__ ((visibility("default"))) +#else +# define CSM_POINT_CLOUD_EXPORT_API +#endif + +// The getCsmVersion method should use CURRENT_CSM_VERSION to +// return the CSM API version that the sensor model/plugin was written to. +#undef CURRENT_CSM_VERSION +#define CURRENT_CSM_VERSION csm::Version(3, 0, 2); + +namespace csm { //*** // STRUCT: ModelCoord //> This structure represents a three-dimensional location (m0,m1,m2 in From fc37296601558b1361533c1e49462aae0d23de0e Mon Sep 17 00:00:00 2001 From: jay Date: Thu, 2 Aug 2018 14:01:34 -0700 Subject: [PATCH 08/25] Adds cmake build --- CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6341a1e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.10) +project(csmapi VERSION 3.0.3 DESCRIPTION "Community Sensor Model API") +set(CMAKE_CXX_STANDARD 11) + +add_library(csmapi SHARED + BundleGM.cpp + CorrelationModel.cpp + csmPointCloud.cpp + Ellipsoid.cpp + FourParameterCorrelationModel.cpp + GeometricModel.cpp + Isd.cpp + LinearDecayCorrelationModel.cpp + ModelIdentifier.cpp + Plugin.cpp + PointCloudGM.cpp + PointCloudIsd.cpp + RasterGM.cpp + SettableEllipsoid.cpp + Version.cpp +) + +file(GLOB HEADER_FILES ${PROJECT_SOURCE_DIR}/*.h) + +set_target_properties(csmapi PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION 3 + PUBLIC_HEADER ${HEADER_FILES} +) + +target_include_directories(csmapi PUBLIC ${PROJECT_SOURCE_DIR}) \ No newline at end of file From 825f52a76d3da2e0247b0aff8e5af3f64f746398 Mon Sep 17 00:00:00 2001 From: jay Date: Thu, 2 Aug 2018 14:08:54 -0700 Subject: [PATCH 09/25] Adds install as well --- CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6341a1e..70b8819 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,11 +21,15 @@ add_library(csmapi SHARED ) file(GLOB HEADER_FILES ${PROJECT_SOURCE_DIR}/*.h) - +message("${HEADER_FILES}") set_target_properties(csmapi PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 3 - PUBLIC_HEADER ${HEADER_FILES} + PUBLIC_HEADER "${HEADER_FILES}" ) -target_include_directories(csmapi PUBLIC ${PROJECT_SOURCE_DIR}) \ No newline at end of file +target_include_directories(csmapi PUBLIC ${PROJECT_SOURCE_DIR}) + +install(TARGETS csmapi + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include/csm) \ No newline at end of file From 8f4280993adcd42493ed297e59818116d98ef4ed Mon Sep 17 00:00:00 2001 From: jlaura Date: Fri, 12 Oct 2018 14:13:51 -0700 Subject: [PATCH 10/25] Update CMakeLists.txt --- CMakeLists.txt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70b8819..5468fed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,17 @@ set_target_properties(csmapi PROPERTIES target_include_directories(csmapi PUBLIC ${PROJECT_SOURCE_DIR}) -install(TARGETS csmapi - LIBRARY DESTINATION lib - PUBLIC_HEADER DESTINATION include/csm) \ No newline at end of file +if(WIN32) + option(CMAKE_USE_WIN32_THREADS_INIT "using WIN32 threads" ON) + option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON) + install(TARGETS csmapi + RUNTIME + DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) + message(${CMAKE_INSTALL_INCLUDEDIR}) +else() + install(TARGETS csmapi LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/csm) +endif() From c0c4a5f4c4cae44f3f46c292d89c4599c4347a0b Mon Sep 17 00:00:00 2001 From: jlaura Date: Fri, 12 Oct 2018 19:34:53 -0700 Subject: [PATCH 11/25] Update CMakeLists.txt --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5468fed..3abeae7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,6 @@ add_library(csmapi SHARED ) file(GLOB HEADER_FILES ${PROJECT_SOURCE_DIR}/*.h) -message("${HEADER_FILES}") set_target_properties(csmapi PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 3 @@ -39,7 +38,6 @@ if(WIN32) PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) - message(${CMAKE_INSTALL_INCLUDEDIR}) else() install(TARGETS csmapi LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/csm) From 78177f09068d6e21637c7a48a0cb12ff6208aa48 Mon Sep 17 00:00:00 2001 From: jlaura Date: Mon, 22 Oct 2018 08:04:17 -0700 Subject: [PATCH 12/25] Update CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3abeae7..d76d62b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ if(WIN32) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) else() + message(${CMAKE_INSTALL_LIBDIR}) install(TARGETS csmapi LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/csm) endif() From ba16296fe9773be82ba284f74afc5549be329530 Mon Sep 17 00:00:00 2001 From: Kelvinrr Date: Wed, 24 Oct 2018 12:53:34 -0700 Subject: [PATCH 13/25] CMakeLists had error in install line --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d76d62b..8a47349 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ if(WIN32) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) else() - message(${CMAKE_INSTALL_LIBDIR}) - install(TARGETS csmapi LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/csm) + message(STATUS "CMAKE INSTALL LIBDIR: ${CMAKE_INSTALL_PREFIX}") + install(TARGETS csmapi LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) + install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/csm) endif() From 3b6f0946b035411be3c3ffe64eb54c5c06d1f8a3 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Thu, 25 Oct 2018 16:13:43 -0700 Subject: [PATCH 14/25] Fixed window install --- CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a47349..8dc7da6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,11 +32,13 @@ target_include_directories(csmapi PUBLIC ${PROJECT_SOURCE_DIR}) if(WIN32) option(CMAKE_USE_WIN32_THREADS_INIT "using WIN32 threads" ON) option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON) - install(TARGETS csmapi - RUNTIME - DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + install(TARGETS csmapi + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME + DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) else() message(STATUS "CMAKE INSTALL LIBDIR: ${CMAKE_INSTALL_PREFIX}") From ece611b74a343fe7028cb534df7c42ecb7141af1 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Thu, 25 Oct 2018 16:28:39 -0700 Subject: [PATCH 15/25] Tweaked windows install locations --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8dc7da6..2b1ddb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,11 +34,11 @@ if(WIN32) option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON) install(TARGETS csmapi LIBRARY - DESTINATION ${CMAKE_INSTALL_LIBDIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/lib RUNTIME - DESTINATION ${CMAKE_INSTALL_LIBDIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/lib PUBLIC_HEADER - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + DESTINATION CMAKE_INSTALL_PREFIX}/include/csm ) else() message(STATUS "CMAKE INSTALL LIBDIR: ${CMAKE_INSTALL_PREFIX}") From 799f29db3656143b3027a17e4a01026b2808cb54 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Thu, 25 Oct 2018 16:42:47 -0700 Subject: [PATCH 16/25] More windows install path fixes --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b1ddb2..d53d519 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,11 +34,11 @@ if(WIN32) option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON) install(TARGETS csmapi LIBRARY - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib + DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/lib RUNTIME - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib + DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/bin PUBLIC_HEADER - DESTINATION CMAKE_INSTALL_PREFIX}/include/csm + DESTINATION CMAKE_INSTALL_PREFIX}/Library/include/csm ) else() message(STATUS "CMAKE INSTALL LIBDIR: ${CMAKE_INSTALL_PREFIX}") From cb70c75c648a071e62e50d2bfde0010edd63c07a Mon Sep 17 00:00:00 2001 From: Jesse Date: Sat, 27 Oct 2018 07:26:33 -0700 Subject: [PATCH 17/25] Fixed typo in windows build --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d53d519..eabc5b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,9 +36,9 @@ if(WIN32) LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/lib RUNTIME - DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/bin + DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/lib PUBLIC_HEADER - DESTINATION CMAKE_INSTALL_PREFIX}/Library/include/csm + DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/include/csm ) else() message(STATUS "CMAKE INSTALL LIBDIR: ${CMAKE_INSTALL_PREFIX}") From e111d5d30addead8637aae72a4bb482b03ac2608 Mon Sep 17 00:00:00 2001 From: jlaura Date: Sat, 5 Jan 2019 19:50:54 -0700 Subject: [PATCH 18/25] Update CMakeLists.txt --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index eabc5b4..6f19db9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,8 @@ if(WIN32) DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/lib PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/include/csm + FILES ${HEADER_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/csm ) else() message(STATUS "CMAKE INSTALL LIBDIR: ${CMAKE_INSTALL_PREFIX}") From 21cea75cd731b9a928d9e4cd2f6712c462f30603 Mon Sep 17 00:00:00 2001 From: jlaura Date: Thu, 10 Jan 2019 19:09:24 -0700 Subject: [PATCH 19/25] Update README --- README | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/README b/README index ee1ddba..4d46aa2 100644 --- a/README +++ b/README @@ -1,14 +1,19 @@ This is the Community Sensor Model base interface library. +About csm +========= + Compilation ----------- The CSM library can be compiled on Linux (tested on RHEL5) i386, x86_64, or IA-64, Solaris SPARC (32 or 64 bit, with or without the "stlport" mode) and x86, and Windows. Use the appropriate Makefile when building. For example: +[![Powered by NumFOCUS](https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](http://numfocus.org) - make -f Makefile.linux64 all install clean +Home: http://github.com/sminster/csm By default, the built files are placed in an architecture subdirectory in the build area. This allows multiple architectures to be built. To specify a different installation directory, set the INSTDIR make variable: +Package license: Public Domain - make -f Makefile.linux64 all install clean INSTDIR=/path/to/csm3/install/dir +Feedstock license: BSD 3-Clause Compiling makes a 'csmapi' shared library (libcsmapi.so.3.1.0 on UNIX, csmapi.dll on Windows). This library must be used when creating both CSM plugins and Sensor Exploitation Tools (SETs) that use CSM. @@ -17,4 +22,36 @@ Windows ------- Windows compilation requires the use of Cygwin to provide tools like 'make' and 'perl'. You should also be sure that Microsoft's Visual C++'s "cl.exe" is in your $PATH and that $INCLUDE and $LIB are set appropriately. When compiling on Windows, the "all" target does not do the right thing. Instead build with: - make -f Makefile.win32 csmapi.dll install clean +Current build status +==================== +[![Linux](https://img.shields.io/circleci/project/github/conda-forge/csm-feedstock/master.svg?label=Linux)](https://circleci.com/gh/conda-forge/csm-feedstock) +[![OSX](https://img.shields.io/travis/conda-forge/csm-feedstock/master.svg?label=macOS)](https://travis-ci.org/conda-forge/csm-feedstock) +[![Windows](https://img.shields.io/appveyor/ci/conda-forge/csm-feedstock/master.svg?label=Windows)](https://ci.appveyor.com/project/conda-forge/csm-feedstock/branch/master) + +Current release info +==================== + +| Name | Downloads | Version | Platforms | +| --- | --- | --- | --- | +| [![Conda Recipe](https://img.shields.io/badge/recipe-csm-green.svg)](https://anaconda.org/conda-forge/csm) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/csm.svg)](https://anaconda.org/conda-forge/csm) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/csm.svg)](https://anaconda.org/conda-forge/csm) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/csm.svg)](https://anaconda.org/conda-forge/csm) | + +Installing csm +============== + +Installing `csm` from the `conda-forge` channel can be achieved by adding `conda-forge` to your channels with: + +``` +conda config --add channels conda-forge +``` + +Once the `conda-forge` channel has been enabled, `csm` can be installed with: + +``` +conda install csm +``` + +It is possible to list all of the versions of `csm` available on your platform with: + +``` +conda search csm --channel conda-forge +``` From 8ddc6877986f051b407a34ff6d6666448f3e093a Mon Sep 17 00:00:00 2001 From: jlaura Date: Thu, 10 Jan 2019 19:09:51 -0700 Subject: [PATCH 20/25] Rename README to README.md --- README => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.md (100%) diff --git a/README b/README.md similarity index 100% rename from README rename to README.md From e38eab98eac4c65e6d19c3961827fb3684ff4fc0 Mon Sep 17 00:00:00 2001 From: Oleg Alexandrov Date: Mon, 15 Jun 2020 18:39:30 -0700 Subject: [PATCH 21/25] Clarify wording I am a bit overly pedantic here, but ECEF is just a Cartesian system that rotates together with the planet. One may define a datum, or one may not, and even then, WGS84 is just one datum for Earth, while ECEF exists also for Mars, etc., and even bodies that are not approximately spherical. --- csm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csm.h b/csm.h index 0a3bc8c..8149513 100644 --- a/csm.h +++ b/csm.h @@ -315,7 +315,7 @@ namespace csm //*** // STRUCT: EcefCoord //> This structure represents a three-dimensional location (x,y,z in meters) - // in the WGS-84 Earth Centered Earth Fixed (ECEF) coordinate system. + // in the Earth-Centered Earth-Fixed (ECEF) coordinate system. // It typically represents an absolute coordinate; the EcefVector structure // is used for velocity and direction vectors. //< From eda05e1e3ec17313a4f18100e13073d7e6129f3d Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Mon, 13 Jul 2020 15:04:20 -0700 Subject: [PATCH 22/25] Added Windows cmake support and CI (#13) * Added Windows cmake support and CI * git is weird * Properply starting conda --- .appveyor.yml | 31 +++++++++++++++++++++++++++++++ .travis.yml | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 24 +++++------------------- 3 files changed, 84 insertions(+), 19 deletions(-) create mode 100644 .appveyor.yml create mode 100644 .travis.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000..a62a223 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,31 @@ +version: '3.0.3.{build}' + +image: Visual Studio 2017 + +platform: + - x64 + +configuration: + - Release + +install: + - call C:\\Miniconda36-x64\Scripts\activate.bat + - conda config --set always_yes yes --set changeps1 no + - conda update -q conda + - conda create -n csm + - conda install -c conda-forge cmake + - conda activate csm + +before_build: + - mkdir build + - cd build + +build_script: + - cmake -DCMAKE_BUILD_TYPE=RELEASE -G "Visual Studio 15 2017 Win64" .. + - cmake --build . --target ALL_BUILD --config Release + +artifacts: + - path: build\Release\csmapi.dll + name: csmapi.dll + - path: build\Release\csmapi.lib + name: csmapi.lib diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bf02b09 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,48 @@ +language: cpp +sudo: false + +branches: + only: + - master + +matrix: + include: + - os: linux + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-7 + env: + - MATRIX_EVAL="CXX=g++-7 && CC=gcc-7" + - os: osx + osx_image: xcode9.4 + env: + - MATRIX_EVAL="CXX=clang++ && CC=clang" + +before_install: + - echo "$TRAVIS_PULL_REQUEST" + - eval "${MATRIX_EVAL}" + +install: + # Install a supported cmake version (>= 3.10) + - | + if [ "$TRAVIS_OS_NAME" == "linux" ]; then + wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; + else + curl -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh; + fi + - bash miniconda.sh -b -p $HOME/miniconda + - source $HOME/miniconda/etc/profile.d/conda.sh + - conda config --set always_yes yes + - conda update -q conda + - conda create -n csm + - conda activate csm + - conda install -c conda-forge cmake + +script: + - mkdir -p build + - cd build + - cmake -DCMAKE_BUILD_TYPE=RELEASE .. + - cmake --build . diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f19db9..18d1a11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,5 @@ cmake_minimum_required(VERSION 3.10) project(csmapi VERSION 3.0.3 DESCRIPTION "Community Sensor Model API") -set(CMAKE_CXX_STANDARD 11) add_library(csmapi SHARED BundleGM.cpp @@ -29,21 +28,8 @@ set_target_properties(csmapi PROPERTIES target_include_directories(csmapi PUBLIC ${PROJECT_SOURCE_DIR}) -if(WIN32) - option(CMAKE_USE_WIN32_THREADS_INIT "using WIN32 threads" ON) - option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON) - install(TARGETS csmapi - LIBRARY - DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/lib - RUNTIME - DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/lib - PUBLIC_HEADER - DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/include/csm - FILES ${HEADER_FILES} - DESTINATION ${CMAKE_INSTALL_PREFIX}/include/csm - ) -else() - message(STATUS "CMAKE INSTALL LIBDIR: ${CMAKE_INSTALL_PREFIX}") - install(TARGETS csmapi LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) - install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/csm) -endif() +set(WINDOWS_EXPORT_ALL_SYMBOLS ON) + +message(STATUS "CMAKE INSTALL LIBDIR: ${CMAKE_INSTALL_PREFIX}") +install(TARGETS csmapi LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) +install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/csm) From 93026655971af1e7737eaf8623c9ba52339069d8 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Mon, 13 Jul 2020 15:44:41 -0700 Subject: [PATCH 23/25] Update README.md --- README.md | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4d46aa2..240e1b6 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,45 @@ This is the Community Sensor Model base interface library. +[![Powered by NumFOCUS](https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](http://numfocus.org) + About csm ========= -Compilation ------------ +Compilation using make +---------------------- The CSM library can be compiled on Linux (tested on RHEL5) i386, x86_64, or IA-64, Solaris SPARC (32 or 64 bit, with or without the "stlport" mode) and x86, and Windows. Use the appropriate Makefile when building. For example: -[![Powered by NumFOCUS](https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](http://numfocus.org) -Home: http://github.com/sminster/csm + make -f Makefile.linux64 all install clean By default, the built files are placed in an architecture subdirectory in the build area. This allows multiple architectures to be built. To specify a different installation directory, set the INSTDIR make variable: -Package license: Public Domain -Feedstock license: BSD 3-Clause + make -f Makefile.linux64 all install clean INSTDIR=/path/to/csm3/install/dir Compiling makes a 'csmapi' shared library (libcsmapi.so.3.1.0 on UNIX, csmapi.dll on Windows). This library must be used when creating both CSM plugins and Sensor Exploitation Tools (SETs) that use CSM. +Building CSM Cmake +------------------ +This repo uses a CMake based build configuration. Run CMake with the desirge configurations and generator to configure your build. Then, run your build system or use cmake. For example: + +``` +mkdir build install +cd build +cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=../install .. +cmake --build . --target install +``` + +will build the library in your `build` directory and install it and the headers into your `install` directory. Windows ------- Windows compilation requires the use of Cygwin to provide tools like 'make' and 'perl'. You should also be sure that Microsoft's Visual C++'s "cl.exe" is in your $PATH and that $INCLUDE and $LIB are set appropriately. When compiling on Windows, the "all" target does not do the right thing. Instead build with: + make -f Makefile.win32 csmapi.dll install clean + +Package license: Public Domain + +Feedstock license: BSD 3-Clause + Current build status ==================== [![Linux](https://img.shields.io/circleci/project/github/conda-forge/csm-feedstock/master.svg?label=Linux)](https://circleci.com/gh/conda-forge/csm-feedstock) @@ -35,8 +53,8 @@ Current release info | --- | --- | --- | --- | | [![Conda Recipe](https://img.shields.io/badge/recipe-csm-green.svg)](https://anaconda.org/conda-forge/csm) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/csm.svg)](https://anaconda.org/conda-forge/csm) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/csm.svg)](https://anaconda.org/conda-forge/csm) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/csm.svg)](https://anaconda.org/conda-forge/csm) | -Installing csm -============== +Installing csm via conda +======================== Installing `csm` from the `conda-forge` channel can be achieved by adding `conda-forge` to your channels with: From 29ccb338a5fcbea85a687653ad29814dcb40357a Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Mon, 27 Jul 2020 08:21:35 -0700 Subject: [PATCH 24/25] Typo Fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 240e1b6..39bd419 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Compiling makes a 'csmapi' shared library (libcsmapi.so.3.1.0 on UNIX, csmapi.dl Building CSM Cmake ------------------ -This repo uses a CMake based build configuration. Run CMake with the desirge configurations and generator to configure your build. Then, run your build system or use cmake. For example: +This repo uses a CMake based build configuration. Run CMake with the desired configurations and generator to configure your build. Then, run your build system or use cmake. For example: ``` mkdir build install From 39b3005a059fcf5ceba71ccfe76168527b7cd1ee Mon Sep 17 00:00:00 2001 From: acpaquette Date: Tue, 9 Jan 2024 13:36:22 -0700 Subject: [PATCH 25/25] Reset Ellipsoid files to master --- Ellipsoid.cpp | 222 +++++++++++++++++++++++++------------------------- Ellipsoid.h | 21 +++-- 2 files changed, 121 insertions(+), 122 deletions(-) diff --git a/Ellipsoid.cpp b/Ellipsoid.cpp index fc23553..45819c7 100644 --- a/Ellipsoid.cpp +++ b/Ellipsoid.cpp @@ -1,111 +1,111 @@ -//############################################################################# -// -// FILENAME: Ellipsoid.cpp -// -// CLASSIFICATION: Unclassified -// -// DESCRIPTION: -// -// This file provides implementation for methods declared in the -// Ellipsoid class. -// -// SOFTWARE HISTORY: -// Date Author Comment -// ----------- ------ ------- -// 06-Aug-2016 Krinsky Initial Coding -// 03-Sep-2021 SCM Use cmath. -// -//############################################################################# - -#ifndef CSM_LIBRARY -#define CSM_LIBRARY -#endif - -#include "Ellipsoid.h" -#include - -namespace csm -{ - //***************************************************************************** - // Ellipsoid::Ellipsoid() - //***************************************************************************** - Ellipsoid::Ellipsoid() - { - setEllipsoid(CSM_WGS84_SEMI_MAJOR_AXIS, CSM_WGS84_SEMI_MINOR_AXIS); - } - - //************************************************************************** - // Ellipsoid::Ellipsoid() - //************************************************************************** - Ellipsoid::Ellipsoid( - double semiMajorRadius, - double semiMinorRadius) - { - setEllipsoid( semiMajorRadius, semiMinorRadius ); - } - - //************************************************************************** - // Ellipsoid::~Ellipsoid() - //************************************************************************** - Ellipsoid::~Ellipsoid() {} - - double Ellipsoid::calculateHeight( - const csm::EcefCoord& geocentric, - double desiredPrecision, - double* achievedPrecision, - csm::WarningList* warnings) const - { - const int MKTR = 10; - double eccSquare = 1.0 - mSemiMinorAxis * mSemiMinorAxis / mSemiMajorAxis / mSemiMajorAxis; - double ep2 = 1.0 - eccSquare; - double d2 = geocentric.x * geocentric.x + geocentric.y * geocentric.y; - double d = sqrt(d2); - double h = 0.0; - int ktr = 0; - double hPrev, r; - - // Suited for points near equator - if (d >= geocentric.z) - { - double tt, zz, n; - double tanPhi = geocentric.z / d; - do - { - hPrev = h; - tt = tanPhi * tanPhi; - r = mSemiMajorAxis / sqrt(1.0 + ep2 * tt); - zz = geocentric.z + r * eccSquare * tanPhi; - n = r * sqrt(1.0 + tt); - h = sqrt(d2 + zz * zz) - n; - tanPhi = zz / d; - ktr++; - } while (MKTR > ktr && fabs(h - hPrev) > desiredPrecision); - } - - // Suited for points near the poles - else - { - double cc, dd, nn; - double cotPhi = d / geocentric.z; - do - { - hPrev = h; - cc = cotPhi * cotPhi; - r = mSemiMajorAxis / sqrt(ep2 + cc); - dd = d - r * eccSquare * cotPhi; - nn = r * sqrt(1.0 + cc) * ep2; - h = sqrt(dd * dd + geocentric.z * geocentric.z) - nn; - cotPhi = dd / geocentric.z; - ktr++; - } while (MKTR > ktr && fabs(h - hPrev) > desiredPrecision); - } - - if (achievedPrecision) - { - *achievedPrecision = fabs(h - hPrev); - } - - return h; - } - -} // namespace csm +//############################################################################# +// +// FILENAME: Ellipsoid.cpp +// +// CLASSIFICATION: Unclassified +// +// DESCRIPTION: +// +// This file provides implementation for methods declared in the +// Ellipsoid class. +// +// SOFTWARE HISTORY: +// Date Author Comment +// ----------- ------ ------- +// 06-Aug-2016 Krinsky Initial Coding +// 03-Sep-2021 SCM Use cmath. +// +//############################################################################# + +#ifndef CSM_LIBRARY +#define CSM_LIBRARY +#endif + +#include "Ellipsoid.h" +#include + +namespace csm +{ + //***************************************************************************** + // Ellipsoid::Ellipsoid() + //***************************************************************************** + Ellipsoid::Ellipsoid() + { + setEllipsoid(CSM_WGS84_SEMI_MAJOR_AXIS, CSM_WGS84_SEMI_MINOR_AXIS); + } + + //************************************************************************** + // Ellipsoid::Ellipsoid() + //************************************************************************** + Ellipsoid::Ellipsoid( + double semiMajorRadius, + double semiMinorRadius) + { + setEllipsoid( semiMajorRadius, semiMinorRadius ); + } + + //************************************************************************** + // Ellipsoid::~Ellipsoid() + //************************************************************************** + Ellipsoid::~Ellipsoid() {} + + double Ellipsoid::calculateHeight( + const csm::EcefCoord& geocentric, + double desiredPrecision, + double* achievedPrecision, + csm::WarningList* warnings) const + { + const int MKTR = 10; + double eccSquare = 1.0 - mSemiMinorAxis * mSemiMinorAxis / mSemiMajorAxis / mSemiMajorAxis; + double ep2 = 1.0 - eccSquare; + double d2 = geocentric.x * geocentric.x + geocentric.y * geocentric.y; + double d = sqrt(d2); + double h = 0.0; + int ktr = 0; + double hPrev, r; + + // Suited for points near equator + if (d >= geocentric.z) + { + double tt, zz, n; + double tanPhi = geocentric.z / d; + do + { + hPrev = h; + tt = tanPhi * tanPhi; + r = mSemiMajorAxis / sqrt(1.0 + ep2 * tt); + zz = geocentric.z + r * eccSquare * tanPhi; + n = r * sqrt(1.0 + tt); + h = sqrt(d2 + zz * zz) - n; + tanPhi = zz / d; + ktr++; + } while (MKTR > ktr && fabs(h - hPrev) > desiredPrecision); + } + + // Suited for points near the poles + else + { + double cc, dd, nn; + double cotPhi = d / geocentric.z; + do + { + hPrev = h; + cc = cotPhi * cotPhi; + r = mSemiMajorAxis / sqrt(ep2 + cc); + dd = d - r * eccSquare * cotPhi; + nn = r * sqrt(1.0 + cc) * ep2; + h = sqrt(dd * dd + geocentric.z * geocentric.z) - nn; + cotPhi = dd / geocentric.z; + ktr++; + } while (MKTR > ktr && fabs(h - hPrev) > desiredPrecision); + } + + if (achievedPrecision) + { + *achievedPrecision = fabs(h - hPrev); + } + + return h; + } + +} // namespace csm diff --git a/Ellipsoid.h b/Ellipsoid.h index dc13556..8293ddc 100644 --- a/Ellipsoid.h +++ b/Ellipsoid.h @@ -39,26 +39,26 @@ #define CSM_WGS84_SEMI_MAJOR_AXIS 6378137.000 #define CSM_WGS84_SEMI_MINOR_AXIS 6356752.3142451794975639665996337 -namespace csm +namespace csm { class CSM_EXPORT_API Ellipsoid { public: - + Ellipsoid(); - //> This constructor defaults to the WGS-84 ellipsoid. - //< + //> This constructor defaults to the WGS-84 ellipsoid. + //< Ellipsoid( double semiMajorRadius, double semiMinorRadius); - //> This constructor sets the ellipsoid to that specified. - //< + //> This constructor sets the ellipsoid to that specified. + //< virtual ~Ellipsoid(); - //> Virtual destructor allows for inheritance. - //< + //> Virtual destructor allows for inheritance. + //< virtual double getSemiMajorRadius() const { @@ -80,7 +80,7 @@ namespace csm const csm::EcefCoord& geocentric, double desiredPrecision = 0.0001, double* achievedPrecision = NULL, - csm::WarningList* warnings = NULL) const; + csm::WarningList* warnings = NULL ) const; //> This method determines the height above the planetary // ellipsoid of the input ground point. Note that while // the input point uses an ECEF coordinate, the point is @@ -97,7 +97,7 @@ namespace csm //> This method sets the semi-major and semi-minor // radii describing the planetary ellipsoid. //< - + protected: double mSemiMajorAxis; @@ -107,4 +107,3 @@ namespace csm } // namespace csm #endif -