GeoHashSwift

GeoHashSwift 是 GeoHash 的 Swift 实现。

GeoHashSwiftDemo.mov

安装 & 使用

GeoHashFramework

GeoHashFramework 是一个框架,提供从坐标计算 GeoHash 的功能。

您可以将其用作您项目的依赖项。

dependencies: [
    .package(url: "https://github.com/fummicc1/GeoHashSwift.git", from: "0.0.4")
]
import GeoHashFramework

let geoHash = GeoHash(latitude: 35.681382, longitude: 139.766084, precision: .mid)
print(geoHash.geoHash) // "xn76urwe"

GeoHashCLI

GeoHashCLI 可执行文件是一个 CLI 工具,它依赖于 GeoHashFramework。

您可以使用此可执行文件从坐标生成 GeoHash。

brew tap fummicc1/geohash
brew install fummicc1/geohash/geohash

使用方法

# Generate GeoHash from latitude and longitude
geohash 35.681236 139.767125
> xn76urx6
# Generate GeoHash from coordinate2d
geohash --coordinate "35.681236,139.767125"
> xn76urx6
dependencies: [
    .package(url: "https://github.com/fummicc1/GeoHashSwift.git", from: "0.0.4")
]

使用方法

# Generate GeoHash from latitude and longitude
swift run geohash 35.681236 139.767125
> xn76urx6
# Generate GeoHash from coordinate2d
swift run geohash --coordinate "35.681236,139.767125"
> xn76urx6

API

模型

GeoHash

GeoHash 是一个 GeoHash 对象。

您可以从 GeoHash 对象获取坐标的二进制值和十六进制值。

更多与 Coordinate2D(纬度,经度)相关的实现位于 GeoHashCoordinate2D.swift 中。

除了计算 GeoHash 之外,此对象还提供以下功能

GeoHashCoordinate2D

GeoHashCoordinate2D 以二进制形式表示一对纬度和经度。

请注意,实际的纬度和经度不会存储在此对象中,因为 GeoHash 的精度无法保证。

功能

相关仓库