Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix 1 Square Km Draw Tool #3157
As a likely effect of the Lodash upgrade, the 1 Square Km draw tool had stopped working correctly. The main functionality is extracted into a utility function and a unit test added for it, with sample values taken from production which doesn't have the bug. Once we have our failing test, the utility function is amended to remove Lodash references in favor of a more direct implementation, which is easier to understand and produces correct results. This restores the draw tool functionality.
The bit of code that generates a 1 square km box from a given point is isolated into a utility function so it can be tested separately. Also add a test that exercises the code with sample values taken from production (where the failure does not occur). The failure is likely due to a subtle change in Lodash behavior caused by the upgrade in 6ac8212.
This was previously done by a dense sequence of Lodash methods, some of which were affected by the Lodash upgrade and had stopped working correctly. Now we make the final array by hand using direct values, foregoing any Lodash functionality. This makes the code easier to read and understand, and the tests pass.