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