Kotlin extensions to convert GeoJSON to JTS and vice-versa.
- Java 8+
Add the dependency in your dependencies { ... }
:
implementation("io.jawg.geojson:geojson-jackson-jts-extensions:1.0.2")
For SNAPSHOT versions add the repository in your repositories { ... }
:
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
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
./gradlew build
./gradlew publish