1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
/**
* \file NETGeographicLib/Geoid.cpp
* \brief Implementation for NETGeographicLib::Geoid class
*
* NETGeographicLib is copyright (c) Scott Heiman (2013)
* GeographicLib is Copyright (c) Charles Karney (2010-2012)
* <charles@karney.com> and licensed under the MIT/X11 License.
* For more information, see
* http://geographiclib.sourceforge.net/
**********************************************************************/
#include "stdafx.h"
#include "GeographicLib/Geoid.hpp"
#include "Geoid.h"
#include "NETGeographicLib.h"
using namespace NETGeographicLib;
//*****************************************************************************
Geoid::!Geoid(void)
{
if ( m_pGeoid != NULL )
{
delete m_pGeoid;
m_pGeoid = NULL;
}
}
//*****************************************************************************
Geoid::Geoid(System::String^ name, System::String^ path,
bool cubic, bool threadsafe)
{
if ( name == nullptr ) throw gcnew GeographicErr("name cannot be a null pointer.");
if ( path == nullptr ) throw gcnew GeographicErr("path cannot be a null pointer.");
try
{
m_pGeoid = new GeographicLib::Geoid(
StringConvert::ManagedToUnmanaged( name ),
StringConvert::ManagedToUnmanaged( path ),
cubic, threadsafe );
}
catch ( std::bad_alloc )
{
throw gcnew GeographicErr( "Failed to allocate memory for a GeographicLib::Geoid" );
}
catch ( const GeographicLib::GeographicErr& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
void Geoid::CacheArea(double south, double west, double north, double east)
{
try
{
m_pGeoid->CacheArea( south, west, north, east );
}
catch ( const std::exception& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
void Geoid::CacheAll()
{
try
{
m_pGeoid->CacheAll();
}
catch ( const std::exception& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
void Geoid::CacheClear()
{
m_pGeoid->CacheClear();
}
//*****************************************************************************
double Geoid::Height(double lat, double lon)
{
try
{
return m_pGeoid->operator()( lat, lon );
}
catch ( const std::exception& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
double Geoid::Height(double lat, double lon,
[System::Runtime::InteropServices::Out] double% gradn,
[System::Runtime::InteropServices::Out] double% grade)
{
try
{
double lgradn, lgrade;
double out = m_pGeoid->operator()( lat, lon, lgradn, lgrade );
gradn = lgradn;
grade = lgrade;
return out;
}
catch ( const std::exception& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
double Geoid::ConvertHeight(double lat, double lon, double h,
ConvertFlag d)
{
try
{
return m_pGeoid->ConvertHeight( lat, lon, h,
static_cast<GeographicLib::Geoid::convertflag>(d) );
}
catch ( const std::exception& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
System::String^ Geoid::DefaultGeoidPath()
{
try
{
return StringConvert::UnmanagedToManaged(
GeographicLib::Geoid::DefaultGeoidPath() );
}
catch ( const std::exception& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
System::String^ Geoid::DefaultGeoidName()
{
try
{
return StringConvert::UnmanagedToManaged(
GeographicLib::Geoid::DefaultGeoidName() );
}
catch ( const std::exception& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
System::String^ Geoid::Description::get()
{ return StringConvert::UnmanagedToManaged(m_pGeoid->Description()); }
//*****************************************************************************
System::String^ Geoid::DateTime::get()
{ return StringConvert::UnmanagedToManaged(m_pGeoid->DateTime()); }
//*****************************************************************************
System::String^ Geoid::GeoidFile::get()
{ return StringConvert::UnmanagedToManaged(m_pGeoid->GeoidFile()); }
//*****************************************************************************
System::String^ Geoid::GeoidName::get()
{ return StringConvert::UnmanagedToManaged(m_pGeoid->GeoidName()); }
//*****************************************************************************
System::String^ Geoid::GeoidDirectory::get()
{ return StringConvert::UnmanagedToManaged(m_pGeoid->GeoidDirectory()); }
//*****************************************************************************
System::String^ Geoid::Interpolation::get()
{ return StringConvert::UnmanagedToManaged(m_pGeoid->Interpolation()); }
//*****************************************************************************
double Geoid::MaxError::get() { return m_pGeoid->MaxError(); }
//*****************************************************************************
double Geoid::RMSError::get() { return m_pGeoid->RMSError(); }
//*****************************************************************************
double Geoid::Offset::get() { return m_pGeoid->Offset(); }
//*****************************************************************************
double Geoid::Scale::get() { return m_pGeoid->Scale(); }
//*****************************************************************************
bool Geoid::ThreadSafe::get() { return m_pGeoid->ThreadSafe(); }
//*****************************************************************************
bool Geoid::Cache::get() { return m_pGeoid->Cache(); }
//*****************************************************************************
double Geoid::CacheWest::get() { return m_pGeoid->CacheWest(); }
//*****************************************************************************
double Geoid::CacheEast::get() { return m_pGeoid->CacheEast(); }
//*****************************************************************************
double Geoid::CacheNorth::get() { return m_pGeoid->CacheNorth(); }
//*****************************************************************************
double Geoid::CacheSouth::get() { return m_pGeoid->CacheSouth(); }
//*****************************************************************************
double Geoid::MajorRadius::get() { return m_pGeoid->MajorRadius(); }
//*****************************************************************************
double Geoid::Flattening::get() { return m_pGeoid->Flattening(); }
|