This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
124 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import com.android.build.api.dsl.LibraryExtension | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
import org.gradle.kotlin.dsl.configure | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension | ||
|
||
class LibraryConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.library") | ||
apply("org.jetbrains.kotlin.android") | ||
} | ||
|
||
extensions.configure<LibraryExtension> { | ||
compileSdk = 34 | ||
buildToolsVersion = "34.0.0" | ||
|
||
defaultConfig { | ||
minSdk = 29 | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
} | ||
|
||
extensions.configure<JavaPluginExtension> { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(17)) | ||
} | ||
} | ||
|
||
extensions.configure<KotlinAndroidProjectExtension> { | ||
jvmToolchain(17) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
plugins { | ||
alias(libs.plugins.pro.library) | ||
} | ||
|
||
android { | ||
namespace = "dev.sanmer.geomag" | ||
|
||
sourceSets { | ||
getByName("main") { | ||
jniLibs.srcDir("src/main/libs") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.kotlinx.datetime) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package dev.sanmer.geomag | ||
|
||
import kotlinx.datetime.LocalDateTime | ||
|
||
object Geomag { | ||
init { | ||
ImplLibrary.load() | ||
} | ||
|
||
external fun toDecimalYears(year: Int, month: Int, day: Int, hour: Int, minute: Int, second: Int): Double | ||
external fun wmm(longitude: Double, latitude: Double, altitude: Double, decimalYears: Double): MagneticField | ||
external fun igrf(longitude: Double, latitude: Double, altitude: Double, decimalYears: Double): MagneticField | ||
|
||
fun toDecimalYears(date: LocalDateTime) = | ||
toDecimalYears(date.year, date.monthNumber, date.dayOfMonth, date.hour, date.minute, date.second) | ||
|
||
fun wmm(longitude: Double, latitude: Double, altitude: Double, date: LocalDateTime) = | ||
wmm(longitude, latitude, altitude, toDecimalYears(date)) | ||
|
||
fun igrf(longitude: Double, latitude: Double, altitude: Double, date: LocalDateTime) = | ||
igrf(longitude, latitude, altitude, toDecimalYears(date)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dev.sanmer.geomag | ||
|
||
|
||
internal object ImplLibrary: Library { | ||
override val name: String = "geomag-jni" | ||
|
||
override fun load() { | ||
System.loadLibrary(name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package dev.sanmer.geomag | ||
|
||
internal interface Library { | ||
val name: String | ||
fun load() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package dev.sanmer.geomag | ||
|
||
data class MagneticField( | ||
val x: Double, | ||
val xDot: Double, | ||
val y: Double, | ||
val yDot: Double, | ||
val z: Double, | ||
val zDot: Double, | ||
val h: Double, | ||
val hDot: Double, | ||
val f: Double, | ||
val fDot: Double, | ||
val d: Double, | ||
val dDot: Double, | ||
val i: Double, | ||
val iDot: Double | ||
) |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters