Skip to content

Commit

Permalink
Adds documentation for encode/decode functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rase-rocks committed Mar 21, 2024
1 parent 86b696d commit 9ce29e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/Geoflash/Geoflash+Decode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ extension Geoflash {

}

/// Decodes a [Geohash](https://en.wikipedia.org/wiki/Geohash) encoded string
///
/// To be a valid Geohash the `String` passed must contain any digits 0-9 and any lower case
/// digit in the set `bcdefghjkmnpqrstuvwxyz`. This is the English language alphabet, excluding
/// the letters `a`, `i`, `l` and `o`
///
/// - Parameter geohash: The `String` value to attempt to decode.
/// - Parameter maxPointDistance: A `Double` value representing the number of decimal places.
///
/// - Returns: An array of [GeoJSON](https://datatracker.ietf.org/doc/html/rfc7946)
/// encoded coordinates.
///
/// - Throws: When passed an invalid geohash.
public static func decode(
geohash: String,
maxPointDistance: Double = 0.000001
Expand Down
9 changes: 9 additions & 0 deletions Sources/Geoflash/Geoflash+Encode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ extension Geoflash {
static let lng = Geoflash.Range(min: -180.0, max: 180.0)!
static let validPrecisions = 1...12

/// Encode latitude/longitude as [Geohash](https://en.wikipedia.org/wiki/Geohash)
///
/// - Parameter latitude: The latitude to be encoded (-90...90 valid values).
/// - Parameter longitude: The longitude to be encoded (-180...180 valid values).
/// - Parameter precision: The count of characters to be included in the result (1...12 valid).
///
/// - Returns: The Geohash encoded string.
///
/// - Throws: On invalid arguments.
public static func encode(
latitude: Double,
longitude: Double,
Expand Down

0 comments on commit 9ce29e5

Please sign in to comment.