Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inverse does not return bbox for 100km grid zone #29

Open
gregsadetsky opened this issue Oct 17, 2018 · 10 comments · May be fixed by #68
Open

inverse does not return bbox for 100km grid zone #29

gregsadetsky opened this issue Oct 17, 2018 · 10 comments · May be fixed by #68
Labels

Comments

@gregsadetsky
Copy link

gregsadetsky commented Oct 17, 2018

Calling mgrs.inverse with a 100km grid zone identifier, such as 16RGU, returns the same latitude, longitude twice instead of a bounding box.

I believe that this is by design -- see https://github.com/proj4js/mgrs/blob/master/mgrs.js#L78

Is there a particular reason why such grid identifiers are not converted into bounding boxes?

Thanks!

@monkeytroy
Copy link

This issue is the reason that I cannot use this project. Well that and I also cannot get a top level grid zone only by the first two letters.

@DanielJDufour
Copy link
Collaborator

Hi, @gregsadetsky and @monkeytroy . Thanks for flagging that this is still a problem. I'll work on a solution and hopefully have it done within a week. Thanks!

@chcolemanjr
Copy link

Any ETA on when this will be fixed?

@DanielJDufour
Copy link
Collaborator

Hi, @chcolemanjr . I'm sorry for the delay. I'll try to have a fix by the end of next week (if not sooner). I'll post here and tag you when that is complete.

@chcolemanjr
Copy link

@DanielJDufour Thanks for response and effort. I appreciate it. While you're looking at the inverse() function could you do a bounds check on the returned lat and longs? I noticed quite a few longitudes coming back with values greater than 180 and less than -180. Thanks again!

@DanielJDufour
Copy link
Collaborator

Will do. Could you share some of these values returning erroneous bounds, so I can add that to the tests?

@chcolemanjr
Copy link

@DanielJDufour Sure. Here you go:

input mgrs: 1CAA returned from inverse(): -188.50987762588105 -71.75574866634604 -188.50987762588105 -71.75574866634604

input mgrs: 56CAA returned from inverse(): 193.28146856805336 -72.8415504450606 193.28146856805336 -72.8415504450606

input mgrs: 59CAA returned from inverse(): 202.73386440303392 -69.22888726751151 202.73386440303392 -69.22888726751151

input mgrs: 60CAA returned from inverse(): 192.09223094379075 -76.11955480636547 192.09223094379075 -76.11955480636547

input mgrs: 1DAA returned from inverse(): -188.50987762588105 -71.75574866634604 -188.50987762588105 -71.75574866634604

input mgrs: 59DAA returned from inverse(): 202.73386440303392 -69.22888726751151 202.73386440303392 -69.22888726751151

input mgrs: 60DAA returned from inverse(): 183.86206214277752 -58.45661355190297 183.86206214277752 -58.45661355190297

input mgrs: 1EAA returned from inverse(): -183.1047976395489 -53.99291942689445 -183.1047976395489 -53.99291942689445

input mgrs: 59EAA returned from inverse(): 188.87806686863846 -52.78874996684672 188.87806686863846 -52.78874996684672

input mgrs: 60EAA returned from inverse(): 183.86206214277752 -58.45661355190297 183.86206214277752 -58.45661355190297

input mgrs: 1FAA returned from inverse(): -183.1047976395489 -53.99291942689445 -183.1047976395489 -53.99291942689445

input mgrs: 59FAA returned from inverse(): 188.87806686863846 -52.78874996684672 188.87806686863846 -52.78874996684672

input mgrs: 60FAA returned from inverse(): 181.72363045788765 -40.55415972586964 181.72363045788765 -40.55415972586964

input mgrs: 1GAA returned from inverse(): -181.4402761156065 -36.062361996833644 -181.4402761156065 -36.062361996833644

input mgrs: 59GAA returned from inverse(): 184.1798329312292 -35.41600726991151 184.1798329312292 -35.41600726991151

input mgrs: 60GAA returned from inverse(): 181.72363045788765 -40.55415972586964 181.72363045788765 -40.55415972586964

input mgrs: 1HAA returned from inverse(): -181.4402761156065 -36.062361996833644 -181.4402761156065 -36.062361996833644

input mgrs: 59HAA returned from inverse(): 184.1798329312292 -35.41600726991151 184.1798329312292 -35.41600726991151

input mgrs: 60HAA returned from inverse(): 181.72363045788765 -40.55415972586964 181.72363045788765 -40.55415972586964

input mgrs: 1JAA returned from inverse(): -180.77735832101328 -18.051740497996235 -180.77735832101328 -18.051740497996235

input mgrs: 59JAA returned from inverse(): 182.26050842477588 -17.76056141770849 182.26050842477588 -17.76056141770849

input mgrs: 60JAA returned from inverse(): 180.8885179770934 -22.559763789039238 180.8885179770934 -22.559763789039238

input mgrs: 1KAA returned from inverse(): -180.77735832101328 -18.051740497996235 -180.77735832101328 -18.051740497996235

input mgrs: 59KAA returned from inverse(): 182.26050842477588 -17.76056141770849 182.26050842477588 -17.76056141770849

input mgrs: 60KAA returned from inverse(): 180.8885179770934 -22.559763789039238 180.8885179770934 -22.559763789039238

input mgrs: 60LAA returned from inverse(): 180.603447968944 -4.5145965610339385 180.603447968944 -4.5145965610339385

input mgrs: 60MAA returned from inverse(): 180.603447968944 -4.5145965610339385 180.603447968944 -4.5145965610339385

input mgrs: 60NAA returned from inverse(): 180.69450574002454 13.541119562220727 180.69450574002454 13.541119562220727

input mgrs: 1PAA returned from inverse(): -180.77735832101328 18.051740497996235 -180.77735832101328 18.051740497996235

input mgrs: 59PAA returned from inverse(): 182.26050842477588 17.76056141770849 182.26050842477588 17.76056141770849

input mgrs: 60PAA returned from inverse(): 180.69450574002454 13.541119562220727 180.69450574002454 13.541119562220727

input mgrs: 1QAA returned from inverse(): -180.77735832101328 18.051740497996235 -180.77735832101328 18.051740497996235

input mgrs: 59QAA returned from inverse(): 182.26050842477588 17.76056141770849 182.26050842477588 17.76056141770849

input mgrs: 60QAA returned from inverse(): 181.21332730451644 31.565646188641153 181.21332730451644 31.565646188641153

input mgrs: 1RAA returned from inverse(): -181.4402761156065 36.062361996833644 -181.4402761156065 36.062361996833644

input mgrs: 59RAA returned from inverse(): 184.1798329312292 35.41600726991151 184.1798329312292 35.41600726991151

input mgrs: 60RAA returned from inverse(): 181.21332730451644 31.565646188641153 181.21332730451644 31.565646188641153

input mgrs: 1SAA returned from inverse(): -181.4402761156065 36.062361996833644 -181.4402761156065 36.062361996833644

input mgrs: 59SAA returned from inverse(): 184.1798329312292 35.41600726991151 184.1798329312292 35.41600726991151

input mgrs: 60SAA returned from inverse(): 181.21332730451644 31.565646188641153 181.21332730451644 31.565646188641153

input mgrs: 1TAA returned from inverse(): -183.1047976395489 53.99291942689445 -183.1047976395489 53.99291942689445

input mgrs: 59TAA returned from inverse(): 188.87806686863846 52.78874996684672 188.87806686863846 52.78874996684672

input mgrs: 60TAA returned from inverse(): 182.52792431499915 49.520335070002616 182.52792431499915 49.520335070002616

input mgrs: 1UAA returned from inverse(): -183.1047976395489 53.99291942689445 -183.1047976395489 53.99291942689445

input mgrs: 59UAA returned from inverse(): 188.87806686863846 52.78874996684672 188.87806686863846 52.78874996684672

input mgrs: 60UAA returned from inverse(): 182.52792431499915 49.520335070002616 182.52792431499915 49.520335070002616

input mgrs: 1VAA returned from inverse(): -188.50987762588105 71.75574866634604 -188.50987762588105 71.75574866634604

input mgrs: 59VAA returned from inverse(): 202.73386440303392 69.22888726751151 202.73386440303392 69.22888726751151

input mgrs: 60VAA returned from inverse(): 186.33498896597143 67.34501697493593 186.33498896597143 67.34501697493593

input mgrs: 1WAA returned from inverse(): -188.50987762588105 71.75574866634604 -188.50987762588105 71.75574866634604

input mgrs: 59WAA returned from inverse(): 202.73386440303392 69.22888726751151 202.73386440303392 69.22888726751151

input mgrs: 60WAA returned from inverse(): 186.33498896597143 67.34501697493593 186.33498896597143 67.34501697493593

@DanielJDufour
Copy link
Collaborator

Thank you @chcolemanjr . I'll look into it. As a fyi, NGA recently changed their MGRS calculations to use the centroid per "Fixed the truncation of MGRS coordinates by adding one-half the precision in MGRS to UTM conversions" (https://earth-info.nga.mil/GandG/update/index.php?action=home). This will require a re-write of some of the code, including the bounding box calculation. Unfortunately, I can't guarantee when this will be done. I'm definitely open to PRs if people can provide them.

@martejj
Copy link

martejj commented Nov 22, 2021

Hi I was planning on using this library but cant due to the issues above, is there ever going to be a fix for this or if not are there any resources youd recommend on how to fix it so I could make a PR?

@DanielJDufour
Copy link
Collaborator

The fix is now available on a branch, please consult #68
or just grab the new version of mgrs.js (pre-built) here: https://github.com/proj4js/mgrs/blob/a67b28ec0df248d2ab524dffddb67401bc26960d/mgrs.js

Because so many people use this library, I need to write some tests that cover the 100k use cases (including toPoint) because I think this code may have indirect untested impact on the results of other function calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants