https://github.com/phansier/h3-kmp
A library to convert Uber's H3 geo-index to LatLng vertices and back for Kotlin Multiplatform: iOS and Android
https://github.com/phansier/h3-kmp
android h3 hacktoberfest kmp
Last synced: 4 months ago
JSON representation
A library to convert Uber's H3 geo-index to LatLng vertices and back for Kotlin Multiplatform: iOS and Android
- Host: GitHub
- URL: https://github.com/phansier/h3-kmp
- Owner: phansier
- License: apache-2.0
- Created: 2025-05-14T12:21:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-10-09T13:33:01.000Z (10 months ago)
- Last Synced: 2026-01-11T18:31:20.930Z (7 months ago)
- Topics: android, h3, hacktoberfest, kmp
- Language: C
- Homepage:
- Size: 576 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# H3-KMP library 
A library to convert Uber's H3 geo-index to LatLng vertices and back for Kotlin Multiplatform: iOS and Android
## Experimental
- Android is ready to use, API may change
- iOS - Work in progress, need help/feedback for convenient publishing
## Instalation
> [!NOTE]
> Replace "0.0.2" with 
### Gradle KMP
```kotlin
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.phansier.h3:library:0.0.2")
/*
# or using version catalog:
# libs.version.toml
[versions]
h3 = "0.0.2"
[libraries]
h3 = { module = "io.github.phansier.h3:library", version.ref = "h3" }
*/
// implementation(libs.h3)
}
}
}
```
### Gradle Android
```kotlin
dependencies {
implementation("io.github.phansier.h3:library:0.0.2")
// implementation(libs.h3)
}
```
## Usage
```kotlin
import com.beriukhov.h3.H3
import com.beriukhov.h3.LatLng as H3LatLng
// https://h3geo.org/#hex=084754a9ffffffff
val polygon: List = H3.vertices("084754a9ffffffff")
// res - Resolution, 0 <= res <= 15
val h3Index: String = geoToH3(H3LatLng(0.0, 0.0), res = 4).toHexString()
```
### Run Sample App
- Android: `open project in Android Studio and run the sample app`
- iOS: `open 'sample/iosApp/iosApp.xcodeproj' in Xcode and run the sample app`
### Publish to MavenLocal
1) Run `./gradlew :library:publishToMavenLocal`
2) Open `~/.m2/repository/io/github/phansier/h3/`
### Inspired by
- [abc-kmm-h3](https://github.com/line/abc-kmm-h3) - not updated 4 years
- [h3-java](https://github.com/uber/h3-java) - [was not supported](https://github.com/uber/h3-java/issues/160) and easy to use in Android when works started
- [h3-go](https://github.com/uber/h3-go) - includes C lib as sources - same approach used here