Skip to content

maplibre/spatial-k

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Spatial K

Maven Central Version License Kotlin Version Documentation API Reference Slack

Introduction

Spatial K is a set of libraries for working with geospatial data in Kotlin.

It includes:

  • GeoJSON implementation and DSL for building GeoJSON objects
  • Port of Turf.js geospatial analysis functions in pure Kotlin
  • Library for working with units of measure

Spatial K supports Kotlin Multiplatform and Java projects.

Getting Started

Add Spatial K to your project:

dependencies {
    implementation("org.maplibre.spatialk:geojson:VERSION")
    implementation("org.maplibre.spatialk:turf:VERSION")
    implementation("org.maplibre.spatialk:units:VERSION")
}

GeoJSON

val sf = buildFeature {
    geometry = Point(longitude = -122.4, latitude = 37.8)
    properties = buildJsonObject {
        put("name", "San Francisco")
    }
}

val json: String = sf.toJson()

Turf

val from = Position(longitude = -122.4, latitude = 37.8)
val to = Position(longitude = -74.0, latitude = 40.7)
val distance = distance(from, to)
val bearing = from.bearingTo(to)

Units

val distance = 5.kilometers
val inMeters = distance.inMeters     // 5000.0
val formatted = distance.toString()  // "5000 m"

See the project site for more info.

Getting Involved

Join the #maplibre Slack channel at OSMUS (get an invite at https://slack.openstreetmap.us/).

Read the CONTRIBUTING.md guide to get familiar with how we do things around here.

About

Spatial K - A set of Kotlin Multiplatform Libraries for working with geospatial data

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors 18