Skip to content

phansier/h3-kmp

Repository files navigation

H3-KMP library Last Version

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.1" with

Gradle KMP

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)
      }
   }
}

Gradle Android

dependencies {
    implementation("io.github.phansier.h3:library:0.0.1")
    // implementation(libs.h3)
}

Usage

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()

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

About

A library to convert Uber's H3 geo-index to LatLng vertices and back for Kotlin Multiplatform: iOS and Android

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages