MGRSCoord.fromString(...)
final MGRSCoordConverter converter = new MGRSCoordConverter(); long err = converter.convertMGRSToGeodetic(MGRSString); return new MGRSCoord(Angle.fromRadians(converter.getLatitude()), Angle.fromRadians(converter.getLongitude()), MGRSString);
MGRSCoord.fromLatLon(...)
/** * Create a MGRS coordinate from a pair of latitude and longitude <code>Angle</code> * with the given precision or number of digits (1 to 5). * * @param latitude the latitude <code>Angle</code>. * @param longitude the longitude <code>Angle</code>. * @param globe the <code>Globe</code> - can be null (will use WGS84). * @param precision the number of digits used for easting and northing (1 to 5). * @return the corresponding <code>MGRSCoord</code>. * @throws IllegalArgumentException if <code>latitude</code> or <code>longitude</code> is null, * or the conversion to MGRS coordinates fails. */ public static MGRSCoord fromLatLon(Angle latitude, Angle longitude, int precision) { if (latitude == null || longitude == null) { throw new IllegalArgumentException("Latitude Or Longitude Is Null"); } final MGRSCoordConverter converter = new MGRSCoordConverter(); long err = converter.convertGeodeticToMGRS(latitude.radians, longitude.radians, precision); if (err != MGRSCoordConverter.MGRS_NO_ERROR) { throw new IllegalArgumentException("MGRS Conversion Error"); } return new MGRSCoord(latitude, longitude, converter.getMGRSString()); }
MGRSCoordConverter.convertUTMToMGRS(...)
Easting = roundMGRS(Easting / divisor) * divisor; Northing = roundMGRS(Northing / divisor) * divisor; getGridValues(Zone); error_code = getLatitudeLetter(Latitude); letters[0] = getLastLetter(); letters[1] = letters[1] + 1; makeMGRSString(Zone, letters, Easting, Northing, Precision);
MGRSCoordConverter.convertMGRSToUTM(...)
UTMCoord UTM = null; MGRSComponents MGRS = breakMGRSString(MGRSString); if (MGRS == null) error_code |= MGRS_STRING_ERROR; hemisphere = AVKey.NORTH; getGridValues(MGRS.zone); grid_northing = grid_northing - TWOMIL; error_code = getLatitudeBandMinNorthing(MGRS.latitudeBand); if (error_code == MGRS_NO_ERROR) latitude = UTM.getLatitude().radians; divisor = Math.pow(10.0, MGRS.precision); error_code = getLatitudeRange(MGRS.latitudeBand); if (error_code == MGRS_NO_ERROR)
MGRSCoordConverter.convertMGRSToGeodetic(...)
long error_code = checkZone(MGRSString); if (error_code == MGRS_NO_ERROR) UTMCoord UTM = convertMGRSToUTM(MGRSString); if (UTM != null) UPSCoord UPS = convertMGRSToUPS(MGRSString); if (UPS != null)
MGRSCoordConverter.convertGeodeticToMGRS(...)
error_code |= convertUPSToMGRS(UPS.getHemisphere(), UPS.getEasting(), UPS.getNorthing(), precision); error_code |= convertUTMToMGRS(UTM.getZone(), latitude, UTM.getEasting(), UTM.getNorthing(), precision);
MGRSCoordConverter.convertMGRSToUPS(...)
double easting, northing; MGRSComponents mgrs = breakMGRSString(MGRS); if (mgrs == null) error_code = this.last_error;