javajsongeojsongeotoolsweb-feature-service

FeatureJSON using CompositeFeatureCollection


I'm making use of FeatureJSON from org.geotools:gt-geojson:15-SNAPSHOT dependency in a Maven project and I'm able to serve GeoJSON for instances of SimpleFeature and SimpleFeatureCollection without any problems. However I find myself wanting to serve WFS with multiple feature types and so I added CompositeFeatureCollection from the org.geotools:gt-wfs:15-SNAPSHOT dependency but when I try and use FeatureJSON.writeFeatureCollection(FeatureCollection, OutputStream) to write a CompositeFeatureCollection I get a NullPointerException in writeFeatureCollection() due to the implementation of getSchema() returning null in CompositeFeatureCollection.

Do any of you know if these two classes (FeatureJSON and CompositeFeatureCollection) by GeoTools are designed to work together, and if so how does one do so? Google so far only turned up documentation results when searching for these two together.

To help with troubleshooting this issue I've created a simplified test project I pushed to GitHub showing the working and not working cases as unit tests plus a hack subclass to CompositeFeatureCollection that returns a dummy SimpleFeatureType and shows how even when this NullPointerException is bypassed this is erroneously used for mapping the contents of each SimpleFeatureCollection in the list that is passed to CompositeFeatureCollection(List<FeatureCollection>) rather than the SimpleFeatureType inside of each SimpleFeatureCollection.


Solution

  • Currently the GeoJSON module doesn't support more than simple features so there would need to be some development work to bring complex features in. If you were interested then a good place to start would be in the unsupported GeoJSONStore which currently provides a ContentStore based DataStore wrapper around the raw GeoJSON module.