Swiftpack.co - emilioschepis/swift-geohash as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by emilioschepis.
emilioschepis/swift-geohash 1.2.0
Implementation of the Geohash algorithm in Swift.
⭐️ 8
🕓 3 years ago
.package(url: "https://github.com/emilioschepis/swift-geohash.git", from: "1.2.0")

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

GitHub

link
Stars: 8
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics