用于地图框的 scala 将'id'字段写入写入矢量切片的特征



我正在使用geotrellis vectorpipe编写mapbox vector图块。

请参阅此处的基本流程:https://geotrellis.github.io/vectorpipe/usage.html

通常,Geojson功能可以具有id字段,因此可以将功能卷到功能上。我需要使用此字段,但是vectorpipe没有(本质上)具有此功能。

这是使用的Feature类型,您可以看到它只有1)A Geometry和2)数据对象D(最终在输出中填充properties)。id没有位置。

https://geotrellis.github.io/scaladocs/latest/index.html#geotrellis.vector.feature

上游有一种称为writeFeatureJsonWithID()的方法,它确实使您在编写Geojson时将id字段注入Feature

https://github.com/locationtech/geotrellis/blob/master/master/src/src/main/scala/scala/geotrellis/geotrellis/io/io/json/json/featureformats.scala#l41-l41-l41-l49

我的问题是:

我已经通过vectorpipe代码(https://github.com/geotrellis/vectorpipe)进行了工作,我无法弄清楚数据是否以Geojson的形式存在于geojson中id,也许使用writeFeatureJsonWithID()或我明确编写的内容。许多转换是隐式的,但它也可能永远不会显式地坐在JSON中。

关于如何在写给矢量瓷砖的最终geojson中获得id字段的任何想法?

编辑

现在,我认为技巧将是找到覆盖.unfeature()方法的方法:

https://github.com/locationtech/geotrellis/blob/master/master/vectortile/src/main/scala/geotrellis/geotrellis/vectortile/layer.scala

问题是internal.vector_tile.Tile是私有的,因此我可以在不裁定项目的情况下进行构建。

最终必须分叉地理特性,在Layer.unfeature()中进行硬码metadata => id函数,并在本地编译以包含在我的项目中。不是理想的,但效果很好。

还在此处打开一个问题:https://github.com/locationtech/geotrellis/issues/2884

最新更新