dotnet/NETGeographicLib/GeoCoords.cpp
Go to the documentation of this file.
1 
11 #include "stdafx.h"
13 #include "GeoCoords.h"
14 #include "UTMUPS.h"
15 #include "NETGeographicLib.h"
16 
17 using namespace NETGeographicLib;
18 
19 const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::GeoCoords";
20 
21 //*****************************************************************************
23 {
24  if ( m_pGeoCoords != NULL )
25  {
26  delete m_pGeoCoords;
27  m_pGeoCoords = NULL;
28  }
29 }
30 
31 //*****************************************************************************
33 {
34  try
35  {
37  }
38  catch ( std::bad_alloc )
39  {
40  throw gcnew GeographicErr( BADALLOC );
41  }
42 }
43 
44 //*****************************************************************************
45 GeoCoords::GeoCoords(System::String^ s, bool centerp, bool longfirst )
46 {
47  try
48  {
50  }
51  catch ( std::bad_alloc )
52  {
53  throw gcnew GeographicErr( BADALLOC );
54  }
55  catch ( const std::exception& err )
56  {
57  throw gcnew GeographicErr( err.what() );
58  }
59 }
60 
61 //*****************************************************************************
62 GeoCoords::GeoCoords(double latitude, double longitude, int zone )
63 {
64  try
65  {
66  m_pGeoCoords = new GeographicLib::GeoCoords(latitude, longitude, zone);
67  }
68  catch ( std::bad_alloc )
69  {
70  throw gcnew GeographicErr( BADALLOC );
71  }
72  catch ( const std::exception& err )
73  {
74  throw gcnew GeographicErr( err.what() );
75  }
76 }
77 
78 //*****************************************************************************
79 GeoCoords::GeoCoords(int zone, bool northp, double easting, double northing)
80 {
81  try
82  {
83  m_pGeoCoords = new GeographicLib::GeoCoords(zone, northp, easting, northing);
84  }
85  catch ( std::bad_alloc )
86  {
87  throw gcnew GeographicErr( BADALLOC );
88  }
89  catch ( const std::exception& err )
90  {
91  throw gcnew GeographicErr( err.what() );
92  }
93 }
94 
95 //*****************************************************************************
96 void GeoCoords::Reset( System::String^ s, bool centerp, bool longfirst )
97 {
98  try
99  {
100  m_pGeoCoords->Reset(StringConvert::ManagedToUnmanaged(s), centerp, longfirst);
101  }
102  catch ( const std::exception& err )
103  {
104  throw gcnew GeographicErr( err.what() );
105  }
106 }
107 
108 //*****************************************************************************
109 void GeoCoords::Reset(double latitude, double longitude, int zone)
110 {
111  try
112  {
113  m_pGeoCoords->Reset(latitude, longitude, zone);
114  }
115  catch ( const std::exception& err )
116  {
117  throw gcnew GeographicErr( err.what() );
118  }
119 }
120 
121 //*****************************************************************************
122 void GeoCoords::Reset(int zone, bool northp, double easting, double northing)
123 {
124  try
125  {
126  m_pGeoCoords->Reset(zone, northp, easting, northing);
127  }
128  catch ( const std::exception& err )
129  {
130  throw gcnew GeographicErr( err.what() );
131  }
132 }
133 
134 //*****************************************************************************
135 void GeoCoords::AltZone::set( int zone )
136 {
137  try
138  {
139  m_pGeoCoords->SetAltZone(zone);
140  }
141  catch ( GeographicLib::GeographicErr err )
142  {
143  throw gcnew GeographicErr( err.what() );
144  }
145 }
146 
147 //*****************************************************************************
148 int GeoCoords::AltZone::get() { return m_pGeoCoords->AltZone(); }
149 
150 //*****************************************************************************
151 double GeoCoords::Latitude::get() { return m_pGeoCoords->Latitude(); }
152 
153 //*****************************************************************************
154 double GeoCoords::Longitude::get() { return m_pGeoCoords->Longitude(); }
155 
156 //*****************************************************************************
157 double GeoCoords::Easting::get() { return m_pGeoCoords->Easting(); }
158 
159 //*****************************************************************************
160 double GeoCoords::Northing::get() { return m_pGeoCoords->Northing(); }
161 
162 //*****************************************************************************
164 
165 //*****************************************************************************
166 double GeoCoords::Scale::get() { return m_pGeoCoords->Scale(); }
167 
168 //*****************************************************************************
169 bool GeoCoords::Northp::get() { return m_pGeoCoords->Northp(); }
170 
171 //*****************************************************************************
173 
174 //*****************************************************************************
175 int GeoCoords::Zone::get() { return m_pGeoCoords->Zone(); }
176 
177 //*****************************************************************************
178 double GeoCoords::AltEasting::get() { return m_pGeoCoords->AltEasting(); }
179 
180 //*****************************************************************************
182 
183 //*****************************************************************************
185 { return m_pGeoCoords->AltConvergence(); }
186 
187 //*****************************************************************************
188 double GeoCoords::AltScale::get() { return m_pGeoCoords->AltScale(); }
189 
190 //*****************************************************************************
192 
193 //*****************************************************************************
194 double GeoCoords::Flattening::get() { return UTMUPS::Flattening(); }
195 
196 //*****************************************************************************
197 System::String^ GeoCoords::GeoRepresentation(int prec, bool longfirst )
198 {
199  return gcnew System::String( m_pGeoCoords->GeoRepresentation(prec, longfirst).c_str() );
200 }
201 
202 //*****************************************************************************
203 System::String^ GeoCoords::DMSRepresentation(int prec, bool longfirst,
204  char dmssep )
205 {
206  return gcnew System::String( m_pGeoCoords->DMSRepresentation(prec, longfirst, dmssep).c_str() );
207 }
208 
209 //*****************************************************************************
210 System::String^ GeoCoords::MGRSRepresentation(int prec)
211 {
212  return gcnew System::String( m_pGeoCoords->MGRSRepresentation(prec).c_str() );
213 }
214 
215 //*****************************************************************************
216 System::String^ GeoCoords::UTMUPSRepresentation(int prec, bool abbrev)
217 {
218  return gcnew System::String( m_pGeoCoords->UTMUPSRepresentation(prec, abbrev).c_str() );
219 }
220 
221 //*****************************************************************************
222 System::String^ GeoCoords::UTMUPSRepresentation(bool northp, int prec, bool abbrev)
223 {
224  return gcnew System::String( m_pGeoCoords->UTMUPSRepresentation(northp, prec, abbrev).c_str() );
225 }
226 
227 //*****************************************************************************
228 System::String^ GeoCoords::AltMGRSRepresentation(int prec)
229 {
230  return gcnew System::String( m_pGeoCoords->AltMGRSRepresentation(prec).c_str() );
231 }
232 
233 //*****************************************************************************
234 System::String^ GeoCoords::AltUTMUPSRepresentation(int prec, bool abbrev)
235 {
236  return gcnew System::String( m_pGeoCoords->AltUTMUPSRepresentation(prec, abbrev).c_str() );
237 }
238 
239 //*****************************************************************************
240 System::String^ GeoCoords::AltUTMUPSRepresentation(bool northp, int prec, bool abbrev)
241 {
242  return gcnew System::String( m_pGeoCoords->AltUTMUPSRepresentation(northp, prec, abbrev).c_str() );
243 }
Math::real Latitude() const
Definition: GeoCoords.hpp:278
Header for NETGeographicLib::NETGeographicLib objects.
Math::real AltNorthing() const
Definition: GeoCoords.hpp:365
Exception class for NETGeographicLib.
const char BADALLOC[]
static std::string ManagedToUnmanaged(System::String^s)
Conversion between geographic coordinates.
Definition: GeoCoords.hpp:49
Math::real Northing() const
Definition: GeoCoords.hpp:293
std::string AltUTMUPSRepresentation(int prec=0, bool abbrev=true) const
Header for GeographicLib::GeoCoords class.
Math::real AltEasting() const
Definition: GeoCoords.hpp:360
GeographicLib::GeoCoords * m_pGeoCoords
Definition: GeoCoords.h:59
Header for NETGeographicLib::GeoCoords class.
Math::real Convergence() const
Definition: GeoCoords.hpp:298
Math::real Scale() const
Definition: GeoCoords.hpp:303
.NET wrapper for GeographicLib::GeoCoords.
Definition: GeoCoords.h:55
std::string GeoRepresentation(int prec=0, bool longfirst=false) const
std::string AltMGRSRepresentation(int prec=0) const
RealScalar s
#define NULL
Definition: ccolamd.c:609
void set(Container &c, Position position, const Value &value)
System::String AltUTMUPSRepresentation(int prec, bool abbrev)
Math::real AltConvergence() const
Definition: GeoCoords.hpp:370
Exception handling for GeographicLib.
Definition: Constants.hpp:389
std::string DMSRepresentation(int prec=0, bool longfirst=false, char dmssep=char(0)) const
Math::real AltScale() const
Definition: GeoCoords.hpp:375
std::string MGRSRepresentation(int prec=0) const
System::String GeoRepresentation(int prec, bool longfirst)
char Hemisphere() const
Definition: GeoCoords.hpp:313
Math::real Easting() const
Definition: GeoCoords.hpp:288
System::String UTMUPSRepresentation(int prec, bool abbrev)
Header for NETGeographicLib::UTMUPS class.
void SetAltZone(int zone=UTMUPS::STANDARD) const
Definition: GeoCoords.hpp:337
Container::iterator get(Container &c, Position position)
void Reset(System::String^s, bool centerp, bool longfirst)
void Reset(const std::string &s, bool centerp=true, bool longfirst=false)
Math::real Longitude() const
Definition: GeoCoords.hpp:283
System::String DMSRepresentation(int prec, bool longfirst, char dmssep)
std::string UTMUPSRepresentation(int prec=0, bool abbrev=true) const


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:07