如何使用地图框“舍入” GeoJSON坐标

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

我正在Windows 10上开发react-native-mapbox-gl应用程序。我需要“四舍五入”上传到该应用程序的GeoJSON点,以便它们出现在房屋区的中央。例如:

图1:在块的东北角添加了一个标记Figure 1: A marker is added on the northeaster corner of a block

图2:标记已“舍入” /“移至”块的地理中心Figure 2: The marker is "rounded" / "moved" to the geographical center of the block

由于无法为每条街道手动创建GeoJSON几何,有没有办法实现这一目标?

android ios mapbox geojson react-native-mapbox-gl
1个回答
0
投票

如果将特定块的边界编码为Polygon特征,则可以使用Turf.js的centroid method计算所述多边形的中心。这将返回一个可用于标记位置的坐标。

[如果您没有这些要素的地理范围,一种选择是使用centroid查询特定半径内的所有建筑物要素,然后创建一个包含这些建筑物的Mapbox Tilequery API对象以用作LatLngBounds定义块的边界。

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