forked from kungfoo/geohash-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix geohash's comparison according to base32 encoded comparison
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12550a3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look at this right away.
12550a3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Fixed geohash comparison to align with base32 encoding standards. The previous method did not correctly account for special cases where the sign of the geohash bits affects comparison. The new approach uses XOR with FIRST_BIT_FLAGGED to handle this properly, ensuring geohashes are compared correctly. Added test coverage to validate this behavior."
here is code that while help u.
@OverRide
public int compareTo(GeoHash o) {
// XOR with FIRST_BIT_FLAGGED to handle sign differences in geohash bits.
int bitsCmp = Long.compare(bits ^ FIRST_BIT_FLAGGED, o.bits ^ FIRST_BIT_FLAGGED);
if (bitsCmp != 0) {
// If bits comparison is non-zero, return the result.
return bitsCmp;
} else {
// If bits are equal, compare by the number of significant bits.
return Integer.compare(significantBits, o.significantBits);
}
}``