Skip to content

Commit

Permalink
Update README (#2)
Browse files Browse the repository at this point in the history
* Update README

* Update README.md

* Update README.md
  • Loading branch information
fummicc1 authored Nov 17, 2024
1 parent a9f41d0 commit 2516f37
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
.package(
url: "https://github.com/apple/swift-argument-parser",
.upToNextMajor(from: "1.5.0")
),
)
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand All @@ -32,7 +32,7 @@ let package = Package(
name: "GeoHashCLI",
dependencies: [
"GeoHashFramework",
.product(name: "ArgumentParser", package: "swift-argument-parser")
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]
),
.testTarget(
Expand Down
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,75 @@

GeoHashSwift is a Swift implementation of GeoHash.

by storing GeoHash in a union-find data structure, and store raw data as binary not 5bits hashed string, improving the accuracy of GeoHash comparison.
[GeoHashCLI](https://github.com/user-attachments/assets/4d19753f-dc6e-4d26-bdce-14b9963f2dde)



## Installation & Usage

### GeoHashFramework

GeoHashFramework is a framework for GeoHash.

You can use it as a dependency of your project.

```swift
dependencies: [
.package(url: "https://github.com/fummicc1/GeoHashSwift.git", from: "0.0.1")
]
```

```swift
import GeoHashFramework

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

### GeoHashCLI

GeoHashCLI executable is a CLI tool for GeoHash.

You can use it to generate GeoHash from latitude and longitude.

<!--
- Install via Homebrew (not yet available)
```sh
brew tap fummicc1/geohash-swift
brew install geohash-swift
```
Usage:
```sh
# Generate GeoHash from latitude and longitude
geohash 35.681236 139.767125
# Generate GeoHash from coordinate2d
geohash --coordinate "35.681236,139.767125"
```
-->

- Install via Swift Package Manager

```swift
dependencies: [
.package(url: "https://github.com/fummicc1/GeoHashSwift.git", from: "0.0.1")
]
```

Usage:

```sh
# 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
```

## APIs

Expand Down
8 changes: 4 additions & 4 deletions Tests/GeoHashFrameworkTests/GeoHashTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct GeoHashTests {
geoHash.geoHash == "xn76urwe"
)
}

@Test
func getBound() async throws {
let actual = GeoHash.getBound(with: .exact(digits: 0))
Expand All @@ -72,17 +72,17 @@ struct GeoHashTests {
GeoHashCoordinate2D(
latitude: -90.0,
longitude: -180.0
)
),
]
#expect(actual == expected)
}

@Test
func getBounds() async throws {
let actual = GeoHash.getBounds(with: .exact(digits: 15))
let count = actual.reduce(0) { partialResult, bound in
partialResult + bound.count
}
print(count == 131072) // 2^15 * 4
print(count == 131072) // 2^15 * 4
}
}

0 comments on commit 2516f37

Please sign in to comment.