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