Many thanks for this great library @bjornharrtell !
Currently jts2geojson is not be able to parse empty geometries in either direction.
This is a correct behavior as GeoJSON processors are not required to parse empty geometries but may do so.
Would you are interested and accept a PR which brings empty geometry parsing into jts2geojson?
JTS already implements this with the additional dependency org.locationtech.jts.io:jts-io-common and the corresponding org.locationtech.jts.io.geojson.GeoJsonWriter.
var geomFactory = new GeometryFactory();
var geoJsonWriter = new org.locationtech.jts.io.geojson.GeoJsonWriter();
geoJsonWriter.setEncodeCRS(false);
var emptyPoint = geomFactory.createPoint();
var geoJson = geoJsonWriter.write(emptyPoint);
// {"type":"Point","coordinates":[]}
A GeoJSON Geometry object of any type other than
"GeometryCollection" has a member with the name "coordinates".
The value of the "coordinates" member is an array. The structure
of the elements in this array is determined by the type of
geometry. GeoJSON processors MAY interpret Geometry objects with
empty "coordinates" arrays as null objects.
Many thanks for this great library @bjornharrtell !
Currently jts2geojson is not be able to parse empty geometries in either direction. This is a correct behavior as GeoJSON processors are not required to parse empty geometries but may do so.
Would you are interested and accept a PR which brings empty geometry parsing into jts2geojson?
JTS already implements this with the additional dependency
org.locationtech.jts.io:jts-io-common
and the correspondingorg.locationtech.jts.io.geojson.GeoJsonWriter
.RFT 7946 Geometry Object