google / google/open-location-code
Wrong logic in computeLatitudePrecision
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 530
- PR merge metrics
- No merged PRs in 30d
Description
`computeLatitudePrecision` uses a wrong logic:
https://github.com/google/open-location-code/blob/bb54a578c4e2d5af10d27e58dd75860cc8f485d5/java/src/main/java/com/google/openlocationcode/OpenLocationCode.java#L683
Instead, it should compare
```
codeLength <= PAIR_CODE_LENGTH
```
The two constants have different semantics, but the same value (namely 10). So this issue is about code cleanness, not about a wrong run-time behavior.
When fixed, `CODE_PRECISION_NORMAL` would just determine the default precision for the two-parameter `encode`. It might then be increased to 11 to match the OLC precision shown by Google Maps for pins, which is about the GPS accuracy in phones.
Contributor guide
Assessment
This issue has not been assessed yet.