File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
commonMain/kotlin/org/maplibre/spatialk/geojson
commonTest/kotlin/org/maplibre/spatialk/geojson Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,9 @@ public data object GeoJson {
5252 is FeatureCollection <* , * > ->
5353 FeatureCollection .serializer(
5454 Geometry .serializer().nullable,
55- when (val props = obj.features.firstNotNullOf { it.properties }) {
55+ when (
56+ val props = obj.features.firstNotNullOfOrNull { it.properties }
57+ ) {
5658 is JsonObject ? -> JsonObject .serializer().nullable
5759 else -> {
5860 @OptIn(InternalSerializationApi ::class )
Original file line number Diff line number Diff line change @@ -404,6 +404,20 @@ class FeatureCollectionTest {
404404 }
405405 }
406406
407+ @Test
408+ fun emptyStarProjection () {
409+ // should fall back to JsonObject properties
410+ val features: FeatureCollection <* , * > = featureCollectionOf()
411+ val json =
412+ """
413+ {
414+ "type": "FeatureCollection",
415+ "features": []
416+ }
417+ """
418+ assertJsonEquals(json, features.toJson())
419+ }
420+
407421 companion object {
408422 private const val SAMPLE_FEATURECOLLECTION = " sample-featurecollection.json"
409423 private const val SAMPLE_FEATURECOLLECTION_BBOX = " sample-feature-collection-with-bbox.json"
You can’t perform that action at this time.
0 commit comments