0.2.0
Breaking Changes
- New serialization APIs
toFeature
andtoGeometryOrNull
functions replaced withfromJson
andfromJsonOrNull
functions.
// Old (0.1.1):
val feature: Feature = "{...}".toFeature()
println(feature.json)
val point = "{not a point}".toGeometryOrNull<Point>()
// New (0.2.0):
val feature: Feature = Feature.fromJson("{...}")
println(feature.json())
val point = Point.fromJsonOrNull("{not a point}")
- Geometry DSLs simplified to reduce how often the unary plus operator is used
// Old (0.1.1):
multiLineString {
+lineString {
+lngLat(45.0, 45.0)
+lngLat(0.0, 0.0)
+lngLat(74.0, -43.2)
}
+someOtherLineString
}
// New (0.2.0):
multiLineString {
lineString {
point(45.0, 45.0)
point(0.0, 0.0)
+lngLat(74.0, -43.2) // unary plus can still be used, but no longer required
}
+someOtherLineString
}
- Feature DSL simplified
// Old (0.1.1)
feature {
geometry = point(0.0, 0.0)
id = "sample"
properties {
"name" to "Sample"
"size" to 6.2
}
}
// New (0.2.0)
feature(geometry = point(0.0, 0.0), id = "sample") { // this: PropertiesBuilder
put("name", "Sample")
put("size", 6.2)
}
Performance Improvements
Serialization performance has been significantly improved. A new "fast" serialization method is now available when encoding GeoJSON objects directly to a JSON string through the GeoJson.json()
function. Serializing through kotlinx.serialization
as normal is also now much faster.
This table outlines the improvements based on benchmarks taken before and after the serialization changes when serializing a FeatureCollection
with 15,000 features:
Encoding (ms/op, lower is better)
Target | Old (0.1.0) | New (kotlinx, 0.2.0) | New (fast, 0.2.0) |
---|---|---|---|
JVM | 834.176 |
250.776 |
71.450 |
JS | 3287.40 |
986.504 |
178.458 |
Native (linuxX64 ) |
5624.209 |
1073.703 |
326.828 |
Decoding (ms/op, lower is better)
Target | Old (0.1.0) | New (0.2.0) |
---|---|---|
JVM | 77.700 |
88.444 |
JS | 423.472 |
383.339 |
Native (linuxX64 ) |
993.008 |
652.600 |
See BENCHMARK for more details.
New Turf Ports
booleanPointInPolygon
(by @jeffdgr8)