pe_geog_to_mgrs_extended |
Converts geographic coordinates into MGRS strings.
int pe_geog_to_mgrs_extended(PE_GEOGCS geogcs, int n, double coord[][2],
int num_digits, int numeric_rounding, int mode, char *mgrs_str[]);
geogcs | A valid geographic coordinate system object |
n | Number of points in the coord array |
coord | Array of points |
num_digits | The precision of output MGRS string |
numeric_rounding | If TRUE, round the UTM coordinates to the precision value. If FALSE, truncate the UTM coordinates to the precision value. |
mode | Determines whether certain spheroids are treated differently. |
mgrs_str | A pointer to an array of MGRS strings |
The military grid reference system (MGRS) is a method of representing
positions with a alphanumeric string. The MGRS string is based on UTM (universal
transverse Mercator) coordinates. The num_digits parameter will determine the
precision of the output string. A value of 5 represents a position to the
nearest meter. A value of zero is the nearest 100 kilometers. The largest
possible value is 8 which is 0.001 meters. The numeric_rounding parameter is
particularly important when the num_digits value is small. Truncating the UTM
coordinates will mean that MGRS string will be in the same square, for instance
the 100 km square. Rounding the UTM coordinates might mean that the MGRS string
uses the next 100 km square, compared to an MGRS string that is truncated or is
more precise. The mode determines whether for certain spheroids, one of the
alphabetical values is changed. The mode values are:
0 Automatic
1 All spheroids are treated the same as WGS84
2 All spheroids are treated the same as Clarke 1866 or Bessel
10 Automatic and a longitude value of +180 is in zone 1
11 All spheroids are treated the same as WGS84 and a longitude value of +180 is
in zone 1
12 All spheroids are treated the same as Clarke 1866 or Bessel and a longitude
value of +180 is in zone 1
The number of points converted.
int i,n, mode;
int ndigits, qround;
double coord[N_MAX][2];
char *mgrs_string[N_MAX];
PE_GEOGCS gcs;
n = 1;
ndigits = 5; /* nearest meter */
qround = 0; /* truncate */
mode = 2; /* treat WGS84 the same as Bessel */
gcs = pe_factory_geogcs(4326); /* WGS 1984 */
coord[0][PE_COORD_LAM] = -117.0;
coord[0][PE_COORD_PHI] = 34.0;
/* MGRS result is 11SNH0000062155 */
i = pe_geog_to_mgrs_extended(gcs, n, coord, ndigits, qround, mode, mgrs_string);
pe_geogcs_del(gcs);