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
|
/**
* \file NETGeographicLib/MGRS.cpp
* \brief Implementation for NETGeographicLib::MGRS 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/MGRS.hpp"
#include "MGRS.h"
#include "NETGeographicLib.h"
using namespace NETGeographicLib;
//*****************************************************************************
void MGRS::Forward(int zone, bool northp, double x, double y,
int prec,
[System::Runtime::InteropServices::Out] System::String^% mgrs)
{
try
{
std::string lmgrs;
GeographicLib::MGRS::Forward( zone, northp, x, y, prec, lmgrs );
mgrs = gcnew System::String( lmgrs.c_str() );
}
catch ( const std::exception& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
void MGRS::Forward(int zone, bool northp, double x, double y, double lat,
int prec, System::String^% mgrs)
{
try
{
std::string lmgrs;
GeographicLib::MGRS::Forward( zone, northp, x, y, lat, prec, lmgrs );
mgrs = gcnew System::String( lmgrs.c_str() );
}
catch ( const std::exception& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
void MGRS::Reverse(System::String^ mgrs,
[System::Runtime::InteropServices::Out] int% zone,
[System::Runtime::InteropServices::Out] bool% northp,
[System::Runtime::InteropServices::Out] double% x,
[System::Runtime::InteropServices::Out] double% y,
[System::Runtime::InteropServices::Out] int% prec,
bool centerp )
{
try
{
double lx, ly;
int lzone, lprec;
bool lnorthp;
GeographicLib::MGRS::Reverse( StringConvert::ManagedToUnmanaged( mgrs ),
lzone, lnorthp, lx, ly, lprec, centerp );
x = lx;
y = ly;
zone = lzone;
prec = lprec;
northp = lnorthp;
}
catch ( const std::exception& err )
{
throw gcnew GeographicErr( err.what() );
}
}
//*****************************************************************************
double MGRS::MajorRadius() { return GeographicLib::UTMUPS::MajorRadius(); }
//*****************************************************************************
double MGRS::Flattening() { return GeographicLib::UTMUPS::Flattening(); }
|