我在 Maven 项目中使用FeatureJSONfromorg.geotools:gt-geojson:15-SNAPSHOT依赖项,并且可以为 GeoJSON 实例提供服务,SimpleFeature并且SimpleFeatureCollection没有任何问题。但是,我发现自己想要为 WFS 提供多种功能类型,因此我CompositeFeatureCollection从org.geotools:gt-wfs:15-SNAPSHOT依赖项中添加了,但是当我尝试使用FeatureJSON.writeFeatureCollection(FeatureCollection, OutputStream)来编写 a时,由于返回in的实现,CompositeFeatureCollection我得到了一个NullPointerExceptionin 。writeFeatureCollection()getSchema()nullCompositeFeatureCollection
你们有谁知道 GeoTools 的这两个类 (FeatureJSON和CompositeFeatureCollection) 是否旨在协同工作,如果是的话,如何做到这一点?到目前为止,Google 仅在同时搜索这两者时才显示文档结果。
为了帮助解决此问题,我创建了一个简化的测试项目,我将其推送到 GitHub,将工作和不工作的案例显示为单元测试以及CompositeFeatureCollection返回虚拟对象的 hack 子类,SimpleFeatureType并显示即使NullPointerException绕过它也会被错误地用于映射SimpleFeatureCollection传递给列表中的 each 的内容,CompositeFeatureCollection(List<FeatureCollection>)而不是SimpleFeatureTypeeach 的内部SimpleFeatureCollection。