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
|
/**
* \file NETGeographicLib/Gnomonic.cpp
* \brief Implementation for NETGeographicLib::Gnomonic 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/Gnomonic.hpp"
#include "Gnomonic.h"
#include "Geodesic.h"
#include "NETGeographicLib.h"
using namespace NETGeographicLib;
const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::Gnomonic";
//*****************************************************************************
Gnomonic::!Gnomonic(void)
{
if ( m_pGnomonic != NULL )
{
delete m_pGnomonic;
m_pGnomonic = NULL;
}
}
//*****************************************************************************
Gnomonic::Gnomonic( Geodesic^ earth )
{
try
{
const GeographicLib::Geodesic* pGeodesic =
reinterpret_cast<const GeographicLib::Geodesic*>(
earth->GetUnmanaged()->ToPointer() );
m_pGnomonic = new GeographicLib::Gnomonic( *pGeodesic );
}
catch ( std::bad_alloc )
{
throw gcnew GeographicErr( BADALLOC );
}
}
//*****************************************************************************
Gnomonic::Gnomonic()
{
try
{
m_pGnomonic = new GeographicLib::Gnomonic( GeographicLib::Geodesic::WGS84() );
}
catch ( std::bad_alloc )
{
throw gcnew GeographicErr( BADALLOC );
}
}
//*****************************************************************************
void Gnomonic::Forward(double lat0, double lon0, double lat, double lon,
[System::Runtime::InteropServices::Out] double% x,
[System::Runtime::InteropServices::Out] double% y,
[System::Runtime::InteropServices::Out] double% azi,
[System::Runtime::InteropServices::Out] double% rk)
{
double lx, ly, lazi, lrk;
m_pGnomonic->Forward( lat0, lon0, lat, lon, lx, ly, lazi, lrk );
x = lx;
y = ly;
azi = lazi;
rk = lrk;
}
//*****************************************************************************
void Gnomonic::Reverse(double lat0, double lon0, double x, double y,
[System::Runtime::InteropServices::Out] double% lat,
[System::Runtime::InteropServices::Out] double% lon,
[System::Runtime::InteropServices::Out] double% azi,
[System::Runtime::InteropServices::Out] double% rk)
{
double llat, llon, lazi, lrk;
m_pGnomonic->Reverse( lat0, lon0, x, y, llat, llon, lazi, lrk );
lat = llat;
lon = llon;
azi = lazi;
rk = lrk;
}
//*****************************************************************************
void Gnomonic::Forward(double lat0, double lon0, double lat, double lon,
[System::Runtime::InteropServices::Out] double% x,
[System::Runtime::InteropServices::Out] double% y)
{
double lx, ly;
m_pGnomonic->Forward( lat0, lon0, lat, lon, lx, ly );
x = lx;
y = ly;
}
//*****************************************************************************
void Gnomonic::Reverse(double lat0, double lon0, double x, double y,
[System::Runtime::InteropServices::Out] double% lat,
[System::Runtime::InteropServices::Out] double% lon)
{
double llat, llon;
m_pGnomonic->Reverse( lat0, lon0, x, y, llat, llon );
lat = llat;
lon = llon;
}
//*****************************************************************************
double Gnomonic::MajorRadius::get() { return m_pGnomonic->MajorRadius(); }
//*****************************************************************************
double Gnomonic::Flattening::get() { return m_pGnomonic->Flattening(); }
|