1

I'm using Nasa's Worldwind java API to convert MGRS strings to lat/lon. However, when my latitude is greater than 85 degrees or less than -85 degrees I get an error. java.lang.IllegalArgumentException: Error during MGRS conversion

Here is my input

MGRSCoord.fromString("ZAD 00000 66856", null);

I'm creating the MGRS from worldwind was well.

Double latitude = 87.0;
Double longitude = 0.0;
Angle latitudeAngle = Angle.fromDegreesLatitude(latitude);
Angle longitudeAngle = Angle.fromDegreesLongitude(longitude);
String coordString = MGRSCoord.fromLatLon(latitudeAngle,longitudeAngle).toString();
MGRSCoord.fromString(coordString, null);

My guest guess is this is frdefault Globe into the conversion by using null, but I tried using actual Globes, but it didn't work, and frankly I didn't really know what to set it to.

1 Answer 1

2

I suspect that conversion actually goes LatLng <==> UTM <==> MGRS

Since UTM is defined as valid for latitudes from 80°S to 84°N, the conversion fails.

1
  • Looking at the code here the conversion is done in the method convertMGRSToGeodetic where they first convert to UTM. They have a line // TODO: polar conversion. So I guess polar conversion isn't supported. I wish somewhere in their documentation it said that. Thanks
    – nanotek
    Dec 21, 2018 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.