1 /**
2  * \file NETGeographicLib/NETGeographicLib.cpp
3  * \brief Implementation for NETGeographicLib Utility functions.
4  *
5  * NETGeographicLib is copyright (c) Scott Heiman (2013)
6  * GeographicLib is Copyright (c) Charles Karney (2010-2012)
7  * <charles@karney.com> and licensed under the MIT/X11 License.
8  * For more information, see
9  * https://geographiclib.sourceforge.io/
10  **********************************************************************/
11 #include "stdafx.h"
12 #include "GeographicLib/Config.h"
13 #include "GeographicLib/Utility.hpp"
14 #include "NETGeographicLib.h"
15 
16 using namespace System::Runtime::InteropServices;
17 using namespace NETGeographicLib;
18 
19 //*****************************************************************************
20 std::string StringConvert::ManagedToUnmanaged( System::String^ s )
21 {
22     System::IntPtr buffer = Marshal::StringToHGlobalAnsi(s);
23     std::string output( reinterpret_cast<const char*>(buffer.ToPointer()) );
24     Marshal::FreeHGlobal(buffer);
25     return output;
26 }
27 
28 //*****************************************************************************
29 System::String^ VersionInfo::GetString()
30 {
31     return gcnew System::String(GEOGRAPHICLIB_VERSION_STRING);
32 }
33 
34 //*****************************************************************************
MajorVersion()35 int VersionInfo::MajorVersion()
36 {
37     return GEOGRAPHICLIB_VERSION_MAJOR;
38 }
39 
40 //*****************************************************************************
MinorVersion()41 int VersionInfo::MinorVersion()
42 {
43     return GEOGRAPHICLIB_VERSION_MINOR;
44 }
45 
46 //*****************************************************************************
Patch()47 int VersionInfo::Patch()
48 {
49     return GEOGRAPHICLIB_VERSION_PATCH;
50 }
51 
52 //*****************************************************************************
53 double Utility::FractionalYear( System::String^ s )
54 {
55     return GeographicLib::Utility::fractionalyear<double>(
56         StringConvert::ManagedToUnmanaged( s ) );
57 }
58