我无法正确获取 turf.centerOfMass() 的数据。
我有一个 featureCollection,可以添加多个多边形。
var polygonlines = [];
//add to polygons etc..
if (polygonlines.length >= 4) {
var feature =
{
"type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [polygonlines] }
}
features.push(feature);
}
}
});
}
var featCollection = {
type: 'FeatureCollection',
features: features
}
我想计算质心、中心和质量中心。
var centroid = turf.centroid(featCollection); //WORKS CORRECTLY
var centre = turf.center(featCollection); //WORKS CORRECTLY
var centreofMass = turf.centerOfMass(featCollection); //FAILS
centerOfMass 计算失败并给出错误: “未捕获的 TypeError TypeError:Qt 不是构造函数”
我能让 centerOfMass 不失败的唯一方法是列出 featcollection 中的单个多边形...但这不是我想要的,我想要多个多边形的中心。 turf 文档说 centerOfMass 可以采用 FeatureCollection,center 和 centroid 可以,而且它们工作得很好......
如何获取多个多边形的质心?
非常感谢
升级到传单版本7.0似乎解决了问题