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
|
/**
* \file NETGeographicLib/DMS.cpp
* \brief Implementation for NETGeographicLib::DMS 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/DMS.hpp"
#include "DMS.h"
#include "NETGeographicLib.h"
using namespace NETGeographicLib;
//*****************************************************************************
double DMS::Decode( System::String^ dms,
[System::Runtime::InteropServices::Out] Flag% ind)
{
try
{
GeographicLib::DMS::flag lind;
double out = GeographicLib::DMS::Decode( StringConvert::ManagedToUnmanaged(dms), lind );
ind = static_cast<Flag>(lind);
return out;
}
catch ( const std::exception& xcpt )
{
throw gcnew GeographicErr( xcpt.what() );
}
}
//*****************************************************************************
double DMS::Decode(System::String^ str)
{
try
{
return GeographicLib::DMS::Decode(StringConvert::ManagedToUnmanaged(str));
}
catch ( const std::exception& xcpt )
{
throw gcnew GeographicErr( xcpt.what() );
}
}
//*****************************************************************************
void DMS::DecodeLatLon(System::String^ dmsa, System::String^ dmsb,
[System::Runtime::InteropServices::Out] double% lat,
[System::Runtime::InteropServices::Out] double% lon,
bool swaplatlong )
{
try
{
double llat, llon;
GeographicLib::DMS::DecodeLatLon( StringConvert::ManagedToUnmanaged( dmsa ),
StringConvert::ManagedToUnmanaged( dmsb ), llat, llon, swaplatlong );
lat = llat;
lon = llon;
}
catch ( const std::exception& xcpt )
{
throw gcnew GeographicErr( xcpt.what() );
}
}
//*****************************************************************************
double DMS::DecodeAngle(System::String^ angstr)
{
try
{
return GeographicLib::DMS::DecodeAngle(StringConvert::ManagedToUnmanaged( angstr ));
}
catch ( const std::exception& xcpt )
{
throw gcnew GeographicErr( xcpt.what() );
}
}
//*****************************************************************************
double DMS::DecodeAzimuth(System::String^ azistr)
{
try
{
return GeographicLib::DMS::DecodeAzimuth(StringConvert::ManagedToUnmanaged( azistr ));
}
catch ( const std::exception& xcpt )
{
throw gcnew GeographicErr( xcpt.what() );
}
}
//*****************************************************************************
System::String^ DMS::Encode(double angle, Component trailing, unsigned prec,
Flag ind, char dmssep)
{
try
{
return StringConvert::UnmanagedToManaged(
GeographicLib::DMS::Encode( angle,
static_cast<GeographicLib::DMS::component>(trailing),
prec,
static_cast<GeographicLib::DMS::flag>(ind),
dmssep )
);
}
catch ( const std::exception& xcpt )
{
throw gcnew GeographicErr( xcpt.what() );
}
}
//*****************************************************************************
System::String^ DMS::Encode(double angle, unsigned prec, Flag ind,
char dmssep )
{
try
{
return StringConvert::UnmanagedToManaged(
GeographicLib::DMS::Encode( angle,
prec,
static_cast<GeographicLib::DMS::flag>(ind),
dmssep )
);
}
catch ( const std::exception& xcpt )
{
throw gcnew GeographicErr( xcpt.what() );
}
}
|