https://github.com/line/abc-kmm-h3
A library to convert Uber's H3 geo-index to LatLng vertices for Kotlin Multiplatform Mobile iOS and Android
https://github.com/line/abc-kmm-h3
android heatmap ios kmm kotlin map multiplatform uber-h3
Last synced: 3 months ago
JSON representation
A library to convert Uber's H3 geo-index to LatLng vertices for Kotlin Multiplatform Mobile iOS and Android
- Host: GitHub
- URL: https://github.com/line/abc-kmm-h3
- Owner: line
- License: apache-2.0
- Created: 2021-10-15T03:08:16.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-20T22:43:10.000Z (over 2 years ago)
- Last Synced: 2025-07-04T23:36:05.307Z (4 months ago)
- Topics: android, heatmap, ios, kmm, kotlin, map, multiplatform, uber-h3
- Language: C
- Homepage:
- Size: 989 KB
- Stars: 13
- Watchers: 9
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

[](http://kotlinlang.org)
[](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile)
[](https://developer.android.com/studio/releases/gradle-plugin)
[](https://gradle.org)
[](https://img.shields.io/badge/platform-ios-lightgray.svg?style=flat)A library to convert Uber's H3 geo-index to LatLng vertices for Kotlin Multiplatform Mobile iOS and android
## Features
- Uber H3 in one interface
- Common interface available on KMM Shared## Requirements
- iOS
- Deployment Target 9.0 or higher
- Android
- minSdkVersion 21## Installation
### Gradle Settings
Add this gradle settings into your `KMP(Kotlin Multiplatform Project)`
#### build.gradle.kts in shared
```kotlin
plugins {
id("com.android.library")
kotlin("multiplatform")
}val h3Lib = "com.linecorp.abc:kmm-h3:0.1.7"
kotlin {
android()
ios {
binaries
.filterIsInstance()
.forEach {
it.baseName = "shared"
it.transitiveExport = true
it.export(h3Lib)
}
}sourceSets {
val commonMain by getting {
dependencies {
implementation(h3Lib)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependencies {
implementation(h3Lib)
api(h3Lib)
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13.2")
implementation("androidx.test:core:1.0.0")
implementation("androidx.test:runner:1.1.0")
implementation("org.robolectric:robolectric:4.2")
}
}
val iosMain by getting {
dependencies {
implementation(h3Lib)
api(h3Lib)
}
}
val iosTest by getting
}
}
```### Project Settings
Android
- Copy and paste `jniLibs` folder into src/main in your projectiOS
- Cocoapods1. Create `Podfile` with below setting in your project root.
```bash
use_frameworks!platform :ios, '9.0'
install! 'cocoapods', :deterministic_uuids => false
target 'iosApp' do
pod 'shared', :path => '../shared/'
end
```2. Run command `pod install` on the terminal
## Usage
### Get Geo Boundaries
Android
```kotlin
val h3Indexes = listOf(
"87283082bffffff",
"872830870ffffff",
"872830820ffffff",
"87283082effffff",
)
val polygons = H3.polygons(h3Indexes)/*
[Polygon(h3Index=87283082bffffff, vertices=[LatLng(lat=37.78529347359727, lng=-122.41077092287513), LatLng(lat=37.79707086149341, lng=-122.40326874464051), LatLng(lat=37.80760100422449, lng=-122.41208776737979), ...
*/
```iOS
```swift
let h3Indexes = [
"87283082bffffff",
"872830870ffffff",
"872830820ffffff",
"87283082effffff",
]let polygons = H3.Companion().polygons(h3Indexes: h3Indexes)
print("polygons", polygons)
/*
[Polygon(h3Index=87283082bffffff, vertices=[LatLng(lat=37.78529347359727, lng=-122.41077092287512), LatLng(lat=37.79707086149341, lng=-122.4032687446405), LatLng(lat=37.80760100422449, lng=-122.41208776737977), ...
*/
```## TODO
- [x] Get Geo Boundaries