用于mapbox矢量切片的scala - 将'id'字段写入写入矢量切片的Features中

问题描述 投票:0回答:1

我正在使用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

https://github.com/locationtech/geotrellis/blob/master/vector/src/main/scala/geotrellis/vector/io/json/FeatureFormats.scala#L41-L49

我的问题是:

我已经通过vectorpipe代码(https://github.com/geotrellis/vectorpipe),我无法弄清楚数据是否存在作为GeoJson,我可以覆盖和注入id,可能使用writeFeatureJsonWithID()或我明确写的东西。许多转换是隐含的,但它也可能永远不会明确地作为json。

有关如何在最终GeoJson中将id字段写入矢量切片的任何想法?

编辑

现在我认为诀窍是找到一种方法来覆盖.unfeature()方法:

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

问题是internal.vector_tile.Tile是私有的,所以我可以在不分支项目的情况下构建它。

scala vector-tiles geotrellis
1个回答
0
投票

结束了必须分叉geotrellis,硬编码metadata => id中的Layer.unfeature()函数并在本地编译以包含在我的项目中。不理想,但它工作正常。

这里也开了一个问题:https://github.com/locationtech/geotrellis/issues/2884

© www.soinside.com 2019 - 2024. All rights reserved.