Skip to content

Incorrect grid ref for polar region (lat 90.0, lon 0.0) #3

@mkrupczak3

Description

@mkrupczak3

I'm writing some Unit Tests for an Android app I'm writing which uses this mgrs-android library. It appears this library gives an incorrect value for the grid of the North pole (the South pole is fine interestingly enough) at latitude 90.0°.

This could be an extremely rare edge case with this library, or it could be that there is a bug with how this library handles the MGRS polar regions.

Version Information:

mgrs-android 2.2.2
Development EnvironmentNot Applicable

Expected Results:

  • According to the Earthpoint.us calculator, the North Pole should have the 1m mgrs as ZAH0000000000. Putting this into Google Maps gives the correct location at the North Pole.

Observed Results:

  • This library gives the grid 31XEV0000097964, which is a point (of a much lower latitude) in the Norwegian Sea off the coast of Norway:
Screenshot 2023-10-30 at 10 12 11 PM Screenshot 2023-10-30 at 10 15 01 PM
  • It could be that this is just an extreme edge case with a latitude of exactly +90.0°. It's possible though that this library may be incorrectly handling many coordinates within the polar regions which use a special convention specific to the MGRS system. If it's the latter case, it would be important to fix this code for reliable use of this code in arctic environments.

Output:

  • See above

Steps to Reproduce:

  1. Set up an Android app with this library
  2. Attempt to calculate the MGRS for 90.0, 0.0

Relevant Code:

package com.openathena;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class CoordTranslatorTest {

    @Test
    public void testToMGRS1m() {
        // values from generated from https://www.earthpoint.us/convert.aspx
        assertEquals("31NAA6602100000", CoordTranslator.toMGRS1m(0.0,0.0));
        assertEquals("ZAH0000000000", CoordTranslator.toMGRS1m(90.0, 0.0));
        assertEquals("BAN0000000000", CoordTranslator.toMGRS1m(-90.0,0.0));
    }

    @Test
    public void testToMGRS10m() {
        // values from generated from https://www.earthpoint.us/convert.aspx
        assertEquals("12SVD97877615", CoordTranslator.toMGRS10m(35.028056, -111.023333));
        assertEquals("18SUJ23400740", CoordTranslator.toMGRS10m(38.897778, -77.036389));
        assertEquals("37UDB13247930", CoordTranslator.toMGRS10m(55.751667, 37.617778));
    }

    @Test
    public void testToMGRS100m() {
        // values from generated from https://www.earthpoint.us/convert.aspx
        assertEquals("45RVL926958", CoordTranslator.toMGRS100m(27.988056, 86.925278));
        assertEquals("54PXT736577", CoordTranslator.toMGRS100m(11.373333, 142.591667));
        assertEquals("19TCG023363", CoordTranslator.toMGRS100m(41.854021, -71.381068));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions