A library to convert Uber's H3 geo-index to LatLng vertices and back for Kotlin Multiplatform: iOS and Android
- Android is ready to use, API may change
- iOS - Work in progress, need help/feedback for convenient publishing
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.phansier.h3:library:0.0.1")
/*
# or using version catalog:
# libs.version.toml
[versions]
h3 = "0.0.1"
[libraries]
h3 = { module = "io.github.phansier.h3:library", version.ref = "h3" }
*/
// implementation(libs.h3)
}
}
}dependencies {
implementation("io.github.phansier.h3:library:0.0.1")
// implementation(libs.h3)
}import com.beriukhov.h3.H3
import com.beriukhov.h3.LatLng as H3LatLng
// https://h3geo.org/#hex=084754a9ffffffff
val polygon: List<H3LatLng> = H3.vertices("084754a9ffffffff")
// res - Resolution, 0 <= res <= 15
val h3Index: String = geoToH3(H3LatLng(0.0, 0.0), res = 4).toHexString()- Android:
open project in Android Studio and run the sample app - iOS:
open 'sample/iosApp/iosApp.xcodeproj' in Xcode and run the sample app
- Run
./gradlew :library:publishToMavenLocal - Open
~/.m2/repository/io/github/phansier/h3/
- abc-kmm-h3 - not updated 4 years
- h3-java - was not supported and easy to use in Android when works started
- h3-go - includes C lib as sources - same approach used here