Implementation of the Geohash algorithm in Swift.
Distributed through Swift Package Manager.
// Package.swift
// ...
dependencies: [
// ...
.package(url: "https://github.com/emilioschepis/swift-geohash.git", from: "1.2.0"),
]
// ...
try Geohash.bounds(of: "u4pruydqq") // ((57.64908..., 10.40740...), (57.64912..., 10.40744...))
try Geohash.decode("u4prs") // (latitude: 57.6..., longitude: 10.4...)
try Geohash.encode(latitude: 57.6, longitude: 10.4) // "u4prs"
try Geohash.encode(latitude: 57.6, longitude: 10.4, precision: .high) // "u4prstv"
try Geohash.encode(latitude: 57.6, longitude: 10.4, precision: .custom(9)) // "u4prstv03"
try Geohash.neighbor(of: "u4prs", direction: .north) // "u4r2h"
try Geohash.neighbors(of: "u4prs") // "u4r2h", "u4r2j", "u4prv"...
try Geohash.neighbors(of: "u4prs", includingCenter: true) // "u4r2h", "u4r2j", "u4prv"... "u4prs"