Skip to content

Implementation of the Geohash algorithm in Swift.

License

Notifications You must be signed in to change notification settings

emilioschepis/swift-geohash

Repository files navigation

Geohash

Implementation of the Geohash algorithm in Swift.

Distributed through Swift Package Manager.

Install

// Package.swift

// ...
dependencies: [
    // ...
    .package(url: "https://github.com/emilioschepis/swift-geohash.git", from: "1.2.0"),
]
// ...

Methods

Bounds

try Geohash.bounds(of: "u4pruydqq") // ((57.64908..., 10.40740...), (57.64912..., 10.40744...))

Decode

try Geohash.decode("u4prs") // (latitude: 57.6..., longitude: 10.4...)

Encode

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"

Neighbors

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"

Resources

About

Implementation of the Geohash algorithm in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages