-
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.
- Loading branch information
Showing
5 changed files
with
52 additions
and
52 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/// A GeoHashPrecision enum represents the bits precision of the GeoHash in binary unit. | ||
/// | ||
/// - low: 30 bits precision. This corresponds to 6 characters of GeoHash. | ||
/// - mid: 40 bits precision. This corresponds to 8 characters of GeoHash. | ||
/// - high: 50 bits precision. This corresponds to 10 characters of GeoHash. | ||
public enum GeoHashBitsPrecision: Sendable, Hashable { | ||
/// 6 digits GeoHash | ||
case low | ||
/// 8 digits GeoHash | ||
case mid | ||
/// 10 digits GeoHash | ||
case high | ||
|
||
/// `digits` **bits** precision. | ||
/// - Note: `digits` must be a multiple of 4 because each GeoHash character is 5 bits. | ||
case exact(digits: Int) | ||
|
||
public var rawValue: Int { | ||
switch self { | ||
case .low: return 6 * 5 | ||
case .mid: return 8 * 5 | ||
case .high: return 10 * 5 | ||
case .exact(let digits): | ||
precondition(digits % 5 == 0) | ||
return digits | ||
} | ||
} | ||
|
||
var format: String { | ||
let rawValue = self.rawValue | ||
return "%0\(rawValue / 5)d" | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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