Giter Site home page Giter Site logo

line / abc-kmm-h3 Goto Github PK

View Code? Open in Web Editor NEW
10.0 9.0 4.0 1013 KB

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

License: Apache License 2.0

Kotlin 28.55% Objective-C 5.68% C 65.78%
uber-h3 kmm kotlin multiplatform map heatmap ios android

abc-kmm-h3's Introduction

abc-kmm-h3: A library to convert Uber's H3 geo-index to LatLng vertices for Kotlin Multiplatform Mobile iOS and android

Kotlin KMM AGP Gradle Platform

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

plugins {
    id("com.android.library")
    kotlin("multiplatform")
}

val h3Lib = "com.linecorp.abc:kmm-h3:0.1.7"

kotlin {
    android()
    ios {
        binaries
            .filterIsInstance<Framework>()
            .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 project

iOS

  • Cocoapods
  1. Create Podfile with below setting in your project root.

    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

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

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

  • Get Geo Boundaries

abc-kmm-h3's People

Contributors

pisces avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

abc-kmm-h3's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.