Geokit is a powerful, type-safe geospatial toolkit for Kotlin Multiplatform. It brings a "Turf-like" experience to the Kotlin ecosystem, providing comprehensive utilities for coordinate math, GeoJSON handling, GML/WFS parsing, and WKT-CRS transformations.
- 📐 Turf-like Math: Geometric calculations, distance measurements, and vector operations.
- 🔥 Fire Weather Index: Hourly FWI calculations (FFMC, DMC, DC, ISI, BUI, FWI) with strict parity to NRCan/CFS reference implementation.
- 🌐 Multi-module Design: Only use what you need (
calculation,geojson,ogc,coordinates,fwi). - 🛠️ CRS Transformations: Parse WKT-CRS and perform coordinate conversions (e.g., EPSG:4326 to EPSG:25832).
- 📦 GeoJSON & GML: First-class support for industry-standard formats via
kotlinx.serialization. - 🏗️ Kotlin Multiplatform: Targets JVM, Android, JS, WasmJS, iOS, and Linux.
Core vector-based coordinate math. Uses a type-safe units library for measurements.
val point1 = Vertex(50.96, 10.99)
val point2 = Vertex(51.00, 11.05)
// Type-safe distance and bearing
val dist: Measure<Length> = point1 distanceTo point2
val bearing: Measure<Angle> = point1 angleTo point2
// Point-in-polygon check
val isInside = vertex inside shapeWKT-CRS parser and transformation pipeline. Supports complex coordinate operations.
val registry = CrsRegistry()
registry.ingest(BuiltInCoordinateReferenceSystems.EPSG4326)
registry.ingest(BuiltInCoordinateReferenceSystems.EPSG25832)
val pipeline = registry.compose(
source = LocalCoordinate(50.963841, 10.998273),
fromEPSG = "EPSG:4326",
toEPSG = "EPSG:25832"
)
val result = pipeline.execute() // Northing/EastingGeoJSON implementation based on kotlinx.serialization. Provides interop
with MapLibre SpatialK.
val position = Position(longitude = 10.99, latitude = 50.96)
val vertex = position.toVertex() // Convert to Geokit Vertex for mathGML and WFS (Web Feature Service) implementation. Handles XML parsing and generation for OGC services.
The "glue" module that maps between GeoJSON models and OGC/GML types.
Hourly Fire Weather Index (FWI) system. A strict Kotlin Multiplatform port of the NRCan/CFS Python reference (NG_FWI.py).
val weatherStream = listOf(
WeatherRow.Input(
id = "STATION1",
date = LocalDate(2023, 7, 1),
hr = 12,
temp = 25.5,
rh = 40.0,
ws = 15.0,
prec = 0.0,
lat = 45.0,
long = -75.0,
timezone = -5.0
)
)
val processed = FireWeatherIndex(weatherStream)
val result = processed.first()
println("FWI: ${result.fwi}")
println("FFMC: ${result.ffmc}")Add the following to your build.gradle.kts:
repositories {
mavenCentral()
// Add your registry if needed
}
dependencies {
implementation("cloud.mallne.geokit:calculation:1.0.0-SNAPSHOT")
implementation("cloud.mallne.geokit:geojson:1.0.0-SNAPSHOT")
implementation("cloud.mallne.geokit:fwi:1.0.0-SNAPSHOT")
// ... other modules
}Contributions are welcome! Please feel free to submit a Pull Request or open an issue.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.