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

WIP: Support 100km precision and using centroid for latitude band letter resolution. #49

Closed
wants to merge 2 commits into from

Conversation

DanielJDufour
Copy link
Collaborator

Changes:

  • you can now pass in 0 for the accuracy value into forward and this will give you the MGRS string at 100km accuracy
  • you can now pass in a third parameter (useCentroid) into forward, which will return an MGRS string using the centroid of the resultant square (not the original latitude/longitude) for determining the Latitude Band Letter.

Open to comments, suggestions and input :-)

@DanielJDufour
Copy link
Collaborator Author

@calvinmetcalf and @ahocevar , open to your thoughts :-)

@calvinmetcalf
Copy link
Member

so what is the tl;dr of the issue, that certain software calculates from the origin but others from the centroid ?

@DanielJDufour
Copy link
Collaborator Author

@calvinmetcalf, yes. That's correct.

@Klaus-Tockloth
Copy link

You introduce code and complexity for only one (very) special / peculiar use case. Not advisable for a general purpose library ...

@tonyVeco
Copy link

I don't know if it is possible, but as it is a special case, you could maybe name it as an independent library (S2-MGRS could it be?), so that the standard version would be not affected by any change/update. :)

export function forward(ll, accuracy) {
accuracy = accuracy || 5; // default accuracy 1m
export function forward(ll, accuracy, useCentroid) {
accuracy = typeof accuracy === 'number' ? accuracy : 5; // default accuracy 1m
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably need a check for a boolean being passed here, in which case that value will be swiched to the useCentroid and accuracy set to 5

@DanielJDufour
Copy link
Collaborator Author

Thanks for the comments everyone. I did some more research into how the latitude band letter is determined in the Sentinel 2 titling grid. It appears that the band letter is based on the first point in the polygon representing the MGRS 100km grid cell and not the centroid or center point of the cell. They just both happen to lead to the same conclusion quite often. My recommendation for people trying to determine a Sentinel 2 Tile based on a latitude/longitude is to create a separate library. Thank you for your patience while I investigated this matter. I'll submit a separate PR for adding the ability to get the 100km MGRS Grid Cell by passing in an accuracy of 0.

You can find my (messy) work doing the research here: https://github.com/DanielJDufour/s2a-tiling-grid-analysis

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

Successfully merging this pull request may close these issues.

4 participants