UNCLASSIFIED

GeographicTranslator
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Classes | Macros | Functions | Variables
MGRS.cpp File Reference
#include <ctype.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include "UPS.h"
#include "UTM.h"
#include "MGRS.h"
#include "EllipsoidParameters.h"
#include "MGRSorUSNGCoordinates.h"
#include "GeodeticCoordinates.h"
#include "UPSCoordinates.h"
#include "UTMCoordinates.h"
#include "CoordinateConversionException.h"
#include "ErrorMessages.h"
#include "WarningMessages.h"

Go to the source code of this file.

Classes

struct  Latitude_Band
 
struct  UPS_Constant
 

Macros

#define EPSILON   1.75e-7 /* approx 1.0e-5 degrees (~1 meter) in radians */
 
#define LETTER_A   0 /* ARRAY INDEX FOR LETTER A */
 
#define LETTER_B   1 /* ARRAY INDEX FOR LETTER B */
 
#define LETTER_C   2 /* ARRAY INDEX FOR LETTER C */
 
#define LETTER_D   3 /* ARRAY INDEX FOR LETTER D */
 
#define LETTER_E   4 /* ARRAY INDEX FOR LETTER E */
 
#define LETTER_F   5 /* ARRAY INDEX FOR LETTER F */
 
#define LETTER_G   6 /* ARRAY INDEX FOR LETTER G */
 
#define LETTER_H   7 /* ARRAY INDEX FOR LETTER H */
 
#define LETTER_I   8 /* ARRAY INDEX FOR LETTER I */
 
#define LETTER_J   9 /* ARRAY INDEX FOR LETTER J */
 
#define LETTER_K   10 /* ARRAY INDEX FOR LETTER K */
 
#define LETTER_L   11 /* ARRAY INDEX FOR LETTER L */
 
#define LETTER_M   12 /* ARRAY INDEX FOR LETTER M */
 
#define LETTER_N   13 /* ARRAY INDEX FOR LETTER N */
 
#define LETTER_O   14 /* ARRAY INDEX FOR LETTER O */
 
#define LETTER_P   15 /* ARRAY INDEX FOR LETTER P */
 
#define LETTER_Q   16 /* ARRAY INDEX FOR LETTER Q */
 
#define LETTER_R   17 /* ARRAY INDEX FOR LETTER R */
 
#define LETTER_S   18 /* ARRAY INDEX FOR LETTER S */
 
#define LETTER_T   19 /* ARRAY INDEX FOR LETTER T */
 
#define LETTER_U   20 /* ARRAY INDEX FOR LETTER U */
 
#define LETTER_V   21 /* ARRAY INDEX FOR LETTER V */
 
#define LETTER_W   22 /* ARRAY INDEX FOR LETTER W */
 
#define LETTER_X   23 /* ARRAY INDEX FOR LETTER X */
 
#define LETTER_Y   24 /* ARRAY INDEX FOR LETTER Y */
 
#define LETTER_Z   25 /* ARRAY INDEX FOR LETTER Z */
 
#define ONEHT   100000.e0 /* ONE HUNDRED THOUSAND */
 
#define TWOMIL   2000000.e0 /* TWO MILLION */
 
#define TRUE   1 /* CONSTANT VALUE FOR TRUE VALUE */
 
#define FALSE   0 /* CONSTANT VALUE FOR FALSE VALUE */
 
#define PI   3.14159265358979323e0
 
#define PI_OVER_2   (PI / 2.0e0)
 
#define PI_OVER_180   (PI / 180.0e0)
 
#define MIN_EASTING   100000.0
 
#define MAX_EASTING   900000.0
 
#define MIN_NORTHING   0.0
 
#define MAX_NORTHING   10000000.0
 
#define MAX_PRECISION   5 /* Maximum precision of easting & northing */
 
#define MIN_MGRS_NON_POLAR_LAT   (-80.0 * ( PI / 180.0 )) /* -80 deg in rad */
 
#define MAX_MGRS_NON_POLAR_LAT   ( 84.0 * ( PI / 180.0 )) /* 84 deg in rad */
 
#define MIN_EAST_NORTH   0.0
 
#define MAX_EAST_NORTH   3999999.0
 
#define _6   (6.0 * (PI / 180.0))
 
#define _8   (8.0 * (PI / 180.0))
 
#define _72   (72.0 * (PI / 180.0))
 
#define _80   (80.0 * (PI / 180.0))
 
#define _80_5   (80.5 * (PI / 180.0))
 
#define _84_5   (84.5 * (PI / 180.0))
 
#define _500000   500000.0
 
#define CLARKE_1866   "CC"
 
#define CLARKE_1880   "CD"
 
#define BESSEL_1841   "BR"
 
#define BESSEL_1841_NAMIBIA   "BN"
 
#define EPSILON2   4.99e-4
 

Functions

double computeScale (int prec)
 
void makeMGRSString (char *MGRSString, long zone, int letters[MGRS_LETTERS], double easting, double northing, long precision)
 
void breakMGRSString (char *MGRSString, long *zone, long letters[MGRS_LETTERS], double *easting, double *northing, long *precision)
 

Variables

const Latitude_Band Latitude_Band_Table [20]
 
const UPS_Constant UPS_Constant_Table [4]
 

Macro Definition Documentation

#define _500000   500000.0

Definition at line 186 of file MGRS.cpp.

#define _6   (6.0 * (PI / 180.0))

Definition at line 179 of file MGRS.cpp.

#define _72   (72.0 * (PI / 180.0))

Definition at line 181 of file MGRS.cpp.

#define _8   (8.0 * (PI / 180.0))

Definition at line 180 of file MGRS.cpp.

#define _80   (80.0 * (PI / 180.0))

Definition at line 182 of file MGRS.cpp.

#define _80_5   (80.5 * (PI / 180.0))

Definition at line 183 of file MGRS.cpp.

#define _84_5   (84.5 * (PI / 180.0))

Definition at line 184 of file MGRS.cpp.

#define BESSEL_1841   "BR"

Definition at line 196 of file MGRS.cpp.

#define BESSEL_1841_NAMIBIA   "BN"

Definition at line 197 of file MGRS.cpp.

#define CLARKE_1866   "CC"

Definition at line 194 of file MGRS.cpp.

#define CLARKE_1880   "CD"

Definition at line 195 of file MGRS.cpp.

#define EPSILON   1.75e-7 /* approx 1.0e-5 degrees (~1 meter) in radians */

Definition at line 131 of file MGRS.cpp.

#define EPSILON2   4.99e-4

Definition at line 199 of file MGRS.cpp.

#define FALSE   0 /* CONSTANT VALUE FOR FALSE VALUE */

Definition at line 163 of file MGRS.cpp.

#define LETTER_A   0 /* ARRAY INDEX FOR LETTER A */

Definition at line 133 of file MGRS.cpp.

#define LETTER_B   1 /* ARRAY INDEX FOR LETTER B */

Definition at line 134 of file MGRS.cpp.

#define LETTER_C   2 /* ARRAY INDEX FOR LETTER C */

Definition at line 135 of file MGRS.cpp.

#define LETTER_D   3 /* ARRAY INDEX FOR LETTER D */

Definition at line 136 of file MGRS.cpp.

#define LETTER_E   4 /* ARRAY INDEX FOR LETTER E */

Definition at line 137 of file MGRS.cpp.

#define LETTER_F   5 /* ARRAY INDEX FOR LETTER F */

Definition at line 138 of file MGRS.cpp.

#define LETTER_G   6 /* ARRAY INDEX FOR LETTER G */

Definition at line 139 of file MGRS.cpp.

#define LETTER_H   7 /* ARRAY INDEX FOR LETTER H */

Definition at line 140 of file MGRS.cpp.

#define LETTER_I   8 /* ARRAY INDEX FOR LETTER I */

Definition at line 141 of file MGRS.cpp.

#define LETTER_J   9 /* ARRAY INDEX FOR LETTER J */

Definition at line 142 of file MGRS.cpp.

#define LETTER_K   10 /* ARRAY INDEX FOR LETTER K */

Definition at line 143 of file MGRS.cpp.

#define LETTER_L   11 /* ARRAY INDEX FOR LETTER L */

Definition at line 144 of file MGRS.cpp.

#define LETTER_M   12 /* ARRAY INDEX FOR LETTER M */

Definition at line 145 of file MGRS.cpp.

#define LETTER_N   13 /* ARRAY INDEX FOR LETTER N */

Definition at line 146 of file MGRS.cpp.

#define LETTER_O   14 /* ARRAY INDEX FOR LETTER O */

Definition at line 147 of file MGRS.cpp.

#define LETTER_P   15 /* ARRAY INDEX FOR LETTER P */

Definition at line 148 of file MGRS.cpp.

#define LETTER_Q   16 /* ARRAY INDEX FOR LETTER Q */

Definition at line 149 of file MGRS.cpp.

#define LETTER_R   17 /* ARRAY INDEX FOR LETTER R */

Definition at line 150 of file MGRS.cpp.

#define LETTER_S   18 /* ARRAY INDEX FOR LETTER S */

Definition at line 151 of file MGRS.cpp.

#define LETTER_T   19 /* ARRAY INDEX FOR LETTER T */

Definition at line 152 of file MGRS.cpp.

#define LETTER_U   20 /* ARRAY INDEX FOR LETTER U */

Definition at line 153 of file MGRS.cpp.

#define LETTER_V   21 /* ARRAY INDEX FOR LETTER V */

Definition at line 154 of file MGRS.cpp.

#define LETTER_W   22 /* ARRAY INDEX FOR LETTER W */

Definition at line 155 of file MGRS.cpp.

#define LETTER_X   23 /* ARRAY INDEX FOR LETTER X */

Definition at line 156 of file MGRS.cpp.

#define LETTER_Y   24 /* ARRAY INDEX FOR LETTER Y */

Definition at line 157 of file MGRS.cpp.

#define LETTER_Z   25 /* ARRAY INDEX FOR LETTER Z */

Definition at line 158 of file MGRS.cpp.

#define MAX_EAST_NORTH   3999999.0

Definition at line 177 of file MGRS.cpp.

#define MAX_EASTING   900000.0

Definition at line 169 of file MGRS.cpp.

#define MAX_MGRS_NON_POLAR_LAT   ( 84.0 * ( PI / 180.0 )) /* 84 deg in rad */

Definition at line 174 of file MGRS.cpp.

#define MAX_NORTHING   10000000.0

Definition at line 171 of file MGRS.cpp.

#define MAX_PRECISION   5 /* Maximum precision of easting & northing */

Definition at line 172 of file MGRS.cpp.

#define MIN_EAST_NORTH   0.0

Definition at line 176 of file MGRS.cpp.

#define MIN_EASTING   100000.0

Definition at line 168 of file MGRS.cpp.

#define MIN_MGRS_NON_POLAR_LAT   (-80.0 * ( PI / 180.0 )) /* -80 deg in rad */

Definition at line 173 of file MGRS.cpp.

#define MIN_NORTHING   0.0

Definition at line 170 of file MGRS.cpp.

#define ONEHT   100000.e0 /* ONE HUNDRED THOUSAND */

Definition at line 160 of file MGRS.cpp.

#define PI   3.14159265358979323e0

Definition at line 164 of file MGRS.cpp.

#define PI_OVER_180   (PI / 180.0e0)

Definition at line 166 of file MGRS.cpp.

#define PI_OVER_2   (PI / 2.0e0)

Definition at line 165 of file MGRS.cpp.

#define TRUE   1 /* CONSTANT VALUE FOR TRUE VALUE */

Definition at line 162 of file MGRS.cpp.

#define TWOMIL   2000000.e0 /* TWO MILLION */

Definition at line 161 of file MGRS.cpp.

Function Documentation

void breakMGRSString ( char *  MGRSString,
long *  zone,
long  letters[MGRS_LETTERS],
double *  easting,
double *  northing,
long *  precision 
)

Definition at line 342 of file MGRS.cpp.

double computeScale ( int  prec)

Definition at line 256 of file MGRS.cpp.

void makeMGRSString ( char *  MGRSString,
long  zone,
int  letters[MGRS_LETTERS],
double  easting,
double  northing,
long  precision 
)

Definition at line 291 of file MGRS.cpp.

Variable Documentation

const Latitude_Band Latitude_Band_Table[20]
Initial value:
= {
{LETTER_C, 1100000.0, -72.0, -80.5, 0.0},
{LETTER_D, 2000000.0, -64.0, -72.0, 2000000.0},
{LETTER_E, 2800000.0, -56.0, -64.0, 2000000.0},
{LETTER_F, 3700000.0, -48.0, -56.0, 2000000.0},
{LETTER_G, 4600000.0, -40.0, -48.0, 4000000.0},
{LETTER_H, 5500000.0, -32.0, -40.0, 4000000.0},
{LETTER_J, 6400000.0, -24.0, -32.0, 6000000.0},
{LETTER_K, 7300000.0, -16.0, -24.0, 6000000.0},
{LETTER_L, 8200000.0, -8.0, -16.0, 8000000.0},
{LETTER_M, 9100000.0, 0.0, -8.0, 8000000.0},
{LETTER_N, 0.0, 8.0, 0.0, 0.0},
{LETTER_P, 800000.0, 16.0, 8.0, 0.0},
{LETTER_Q, 1700000.0, 24.0, 16.0, 0.0},
{LETTER_R, 2600000.0, 32.0, 24.0, 2000000.0},
{LETTER_S, 3500000.0, 40.0, 32.0, 2000000.0},
{LETTER_T, 4400000.0, 48.0, 40.0, 4000000.0},
{LETTER_U, 5300000.0, 56.0, 48.0, 4000000.0},
{LETTER_V, 6200000.0, 64.0, 56.0, 6000000.0},
{LETTER_W, 7000000.0, 72.0, 64.0, 6000000.0},
{LETTER_X, 7900000.0, 84.5, 72.0, 6000000.0}}

Definition at line 210 of file MGRS.cpp.

const UPS_Constant UPS_Constant_Table[4]
Initial value:
=
{{LETTER_A, LETTER_J, LETTER_Z, LETTER_Z, 800000.0, 800000.0},
{LETTER_B, LETTER_A, LETTER_R, LETTER_Z, 2000000.0, 800000.0},
{LETTER_Y, LETTER_J, LETTER_Z, LETTER_P, 800000.0, 1300000.0},
{LETTER_Z, LETTER_A, LETTER_J, LETTER_P, 2000000.0, 1300000.0}}

Definition at line 243 of file MGRS.cpp.