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

Short code to full code recovery has a bug #37

Closed
drinckes opened this issue Feb 10, 2016 · 1 comment
Closed

Short code to full code recovery has a bug #37

drinckes opened this issue Feb 10, 2016 · 1 comment

Comments

@drinckes
Copy link
Contributor

In some cases, recovering a short code to a full code does not return the nearest match.

Calling recoverNearest('22+', 14.9333, -23.5125) returns 796RXF22+. This is not correct - the nearest match is 796RXG22+.

The problem seems to be with the step where the reference latitude and longitude are rounded down before generating the candidate code. In the above example, it should generate a code whose center is at most .05 degrees from the reference location, but due to the rounding down it is .08 degrees away.

It appears that removing the rounding down step entirely fixes this.

@drinckes
Copy link
Contributor Author

Some more detail. Rounding the reference location, can result in a padding section that is more than one cell away from the correct position. The reason this is happening is that the code is using Math.floor. Either changing this to Math.round, or removing it entirely, fixes the problem.

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

No branches or pull requests

1 participant