NETGeographicLib  1.50.1
GARS.h
Go to the documentation of this file.
1 /**
2  * \file NETGeographicLib/GARS.h
3  * \brief Header for NETGeographicLib::GARS class
4  *
5  * NETGeographicLib is copyright (c) Scott Heiman (2013-2015)
6  * GeographicLib is Copyright (c) Charles Karney (2010-2012)
7  * <charles@karney.com> and licensed under the MIT/X11 License.
8  * For more information, see
9  * https://geographiclib.sourceforge.io/
10  **********************************************************************/
11 #pragma once
12 
13 namespace NETGeographicLib
14 {
15  /**
16  * \brief .NET Wrapper for GeographicLib::GARS
17  *
18  * This class allows .NET applications to access GeographicLib::GARS.
19  *
20  * The Global Area Reference System is described in
21  * - https://en.wikipedia.org/wiki/Global_Area_Reference_System
22  * - http://earth-info.nga.mil/GandG/coordsys/grids/gars.html
23  * .
24  * It provides a compact string representation of a geographic area
25  * (expressed as latitude and longitude). The classes Georef and Geohash
26  * implement similar compact representations.
27  *
28  * C# Example:
29  * \include example-GARS.cs
30  * Managed C++ Example:
31  * \include example-GARS.cpp
32  * Visual Basic Example:
33  * \include example-GARS.vb
34  **********************************************************************/
35  public ref class GARS
36  {
37  // all memebers of this class are static so the constructor is hidden.
38  GARS() {}
39 
40  public:
41 
42  /**
43  * Convert from geographic coordinates to GARS.
44  *
45  * @param[in] lat latitude of point (degrees).
46  * @param[in] lon longitude of point (degrees).
47  * @param[in] prec the precision of the resulting GARS.
48  * @param[out] gars the GARS string.
49  * @exception GeographicErr if \e lat is not in [&minus;90&deg;,
50  * 90&deg;] or if memory for \e gars can't be allocated.
51  *
52  * \e prec specifies the precision of \e gars as follows:
53  * - \e prec = 0 (min), 30' precision, e.g., 006AG;
54  * - \e prec = 1, 15' precision, e.g., 006AG3;
55  * - \e prec = 2 (max), 5' precision, e.g., 006AG39.
56  *
57  * If \e lat or \e lon is NaN, then \e gars is set to "INVALID".
58  **********************************************************************/
59  static void Forward(double lat, double lon, int prec,
60  [System::Runtime::InteropServices::Out] System::String^% gars);
61 
62  /**
63  * Convert from GARS to geographic coordinates.
64  *
65  * @param[in] gars the GARS.
66  * @param[out] lat latitude of point (degrees).
67  * @param[out] lon longitude of point (degrees).
68  * @param[out] prec the precision of \e gars.
69  * @param[in] centerp if true (the default) return the center of the
70  * \e gars, otherwise return the south-west corner.
71  * @exception GeographicErr if \e gars is illegal.
72  *
73  * The case of the letters in \e gars is ignored. \e prec is in the range
74  * [0, 2] and gives the precision of \e gars as follows:
75  * - \e prec = 0 (min), 30' precision, e.g., 006AG;
76  * - \e prec = 1, 15' precision, e.g., 006AG3;
77  * - \e prec = 2 (max), 5' precision, e.g., 006AG39.
78  *
79  * If the first 3 characters of \e gars are "INV", then \e lat and \e lon
80  * are set to NaN and \e prec is unchanged.
81  **********************************************************************/
82  static void Reverse( System::String^ gars,
83  [System::Runtime::InteropServices::Out] double% lat,
84  [System::Runtime::InteropServices::Out] double% lon,
85  [System::Runtime::InteropServices::Out] int% prec,
86  bool centerp);
87 
88  /**
89  * The angular resolution of a GARS.
90  *
91  * @param[in] prec the precision of the GARS.
92  * @return the latitude-longitude resolution (degrees).
93  *
94  * Internally, \e prec is first put in the range [0, 2].
95  **********************************************************************/
96  static double Resolution(int prec);
97 
98  /**
99  * The GARS precision required to meet a given geographic resolution.
100  *
101  * @param[in] res the minimum of resolution in latitude and longitude
102  * (degrees).
103  * @return GARS precision.
104  *
105  * The returned length is in the range [0, 2].
106  **********************************************************************/
107  static int Precision(double res);
108  };
109 } // namespace NETGeographicLib
NETGeographicLib::GARS::Resolution
static double Resolution(int prec)
NETGeographicLib::GARS
.NET Wrapper for GeographicLib::GARS
Definition: GARS.h:35
NETGeographicLib::GARS::Reverse
static void Reverse(System::String^ gars, [System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon, [System::Runtime::InteropServices::Out] int% prec, bool centerp)
NETGeographicLib::GARS::GARS
GARS()
Definition: GARS.h:38
NETGeographicLib::GARS::Forward
static void Forward(double lat, double lon, int prec, [System::Runtime::InteropServices::Out] System::String^% gars)
NETGeographicLib::GARS::Precision
static int Precision(double res)
NETGeographicLib
Definition: Accumulator.h:13