我正在使用geotrellis vectorpipe编写MapBox矢量切片。
看到这里的基本流程:https://geotrellis.github.io/vectorpipe/usage.html
通常,GeoJson功能可以具有id
字段,因此功能可以汇总到FeatureCollections中。我需要使用这个字段,但vectorpipe(本机地)没有这个功能。
这是使用的Feature
类型,你可以看到它只有1)a Geometry
和2)数据对象D
(最终在输出中填充properties
)的空间。没有id
的地方。
https://geotrellis.github.io/scaladocs/latest/index.html#geotrellis.vector.Feature
上游有一个名为writeFeatureJsonWithID()
的方法,它可以让你在编写GeoJson时将id
字段注入Feature
。
我的问题是:
我已经通过vectorpipe代码(https://github.com/geotrellis/vectorpipe),我无法弄清楚数据是否存在作为GeoJson,我可以覆盖和注入id
,可能使用writeFeatureJsonWithID()
或我明确写的东西。许多转换是隐含的,但它也可能永远不会明确地作为json。
有关如何在最终GeoJson中将id
字段写入矢量切片的任何想法?
编辑
现在我认为诀窍是找到一种方法来覆盖.unfeature()
方法:
问题是internal.vector_tile.Tile
是私有的,所以我可以在不分支项目的情况下构建它。
结束了必须分叉geotrellis,硬编码metadata => id
中的Layer.unfeature()
函数并在本地编译以包含在我的项目中。不理想,但它工作正常。
这里也开了一个问题:https://github.com/locationtech/geotrellis/issues/2884