google / open-location-code

Open Location Code is a library to generate short codes, called "plus codes", that can be used as digital addresses where street addresses don't exist.
https://plus.codes
Apache License 2.0
4.06k stars 471 forks source link

Normalize longitude without looping #460

Closed bocops closed 2 years ago

bocops commented 3 years ago

Change normalizeLongitude to remove loops. Returned value is a normalized longitude in range [-180;+180[

I'm not sure how much commenting the final line really needs, so please advise.

If accepted, this fixes https://github.com/google/open-location-code/issues/373 for the Java implementation.

bocops commented 3 years ago

Note: #373 should probably NOT be closed by this, as there might be other implementations that still need to be fixed.

sonyaa commented 2 years ago

Please add a couple test cases to https://github.com/google/open-location-code/blob/main/test_data/encoding.csv -- it currently has test cases for ">=180", but nothing for ">360" or "<-360". Thank you!