scala for mapbox vector tiles - 将 'id' 字段放入写入矢量瓦片的要素中
scala for mapbox vector tiles - getting an 'id' field into the Features written to vector tiles
我正在使用 geotrellis vectorpipe 编写 MapBox 矢量切片。
基本流程请看这里:https://geotrellis.github.io/vectorpipe/usage.html
通常 GeoJson Features 可以有一个 id
字段,这样 Features 就可以汇总到 FeatureCollections 中。我需要使用这个字段,但是 vectorpipe 没有(原生)这个功能。
这是使用的 Feature
类型,您可以看到它只有 space 用于 1) 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),但我无法弄清楚 if/where 数据以 GeoJson 的形式存在,我可以覆盖并注入 id
,也许使用 writeFeatureJsonWithID()
或我明确写的东西。许多转换是隐式的,但它也可能永远不会显式地设置为 json.
关于如何将最终 GeoJson 中的 id
字段写入矢量切片有什么想法吗?
编辑
现在我认为诀窍是找到一种方法来覆盖这里的 .unfeature()
方法:
问题是 internal.vector_tile.Tile
是私有的,所以我可以在不分叉项目的情况下构建它。
最终不得不分叉 geotrellis,在 Layer.unfeature()
中硬编码一个 metadata => id
函数并在本地编译以包含在我的项目中。不理想,但效果很好。
这里也开了个issue:https://github.com/locationtech/geotrellis/issues/2884
我正在使用 geotrellis vectorpipe 编写 MapBox 矢量切片。
基本流程请看这里:https://geotrellis.github.io/vectorpipe/usage.html
通常 GeoJson Features 可以有一个 id
字段,这样 Features 就可以汇总到 FeatureCollections 中。我需要使用这个字段,但是 vectorpipe 没有(原生)这个功能。
这是使用的 Feature
类型,您可以看到它只有 space 用于 1) 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),但我无法弄清楚 if/where 数据以 GeoJson 的形式存在,我可以覆盖并注入 id
,也许使用 writeFeatureJsonWithID()
或我明确写的东西。许多转换是隐式的,但它也可能永远不会显式地设置为 json.
关于如何将最终 GeoJson 中的 id
字段写入矢量切片有什么想法吗?
编辑
现在我认为诀窍是找到一种方法来覆盖这里的 .unfeature()
方法:
问题是 internal.vector_tile.Tile
是私有的,所以我可以在不分叉项目的情况下构建它。
最终不得不分叉 geotrellis,在 Layer.unfeature()
中硬编码一个 metadata => id
函数并在本地编译以包含在我的项目中。不理想,但效果很好。
这里也开了个issue:https://github.com/locationtech/geotrellis/issues/2884