takimafr / geojson-jackson-jts-extensions

Kotlin extensions to convert GeoJSON to JTS and vice-versa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JTS extensions for GeoJSON

Kotlin extensions to convert GeoJSON to JTS and vice-versa.

Requirements

  • Java 8+

Dependency

Add the dependency in your dependencies { ... }:

implementation("io.jawg.geojson:geojson-jackson-jts-extensions:1.0.1")

For SNAPSHOT versions add the repository in your repositories { ... }:

maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }

Usage

Convert a GeoJSON Geometry to a JTS Geometry:

val geoJsonGeometry: Geometry = ...
val jtsGeometry = geoJsonGeometry.toJts()

// or on Features
val feature: Feature = ...
val jtsGeometry = feature.toJts() // feature id and properties will be stored in userData

Convert a JTS Geometry to a GeoJSON Geometry:

val jtsGeometry = ...
val geoJsonGeometry = jtsGeometry.toGeoJson()

// or to Feature
val jtsGeometry = ...
val feature = jtsGeometry.toFeature() // feature id and properties will be retrieved from userData

Build the library

./gradlew build

Publish the library

./gradlew publish

About

Kotlin extensions to convert GeoJSON to JTS and vice-versa

License:Apache License 2.0


Languages

Language:Kotlin 100.0%