我正在获取Geojson LineString数据,并且我想找到线串的中心点以创建要显示在地图上的geohash。及其转换和创建geohash,但是当将这些数据提取以显示在地图上时,我得到了生产错误。请建议如何找到正确的中心点数据来创建果仁糖。
这同样适用于多行字符串,但不适用于行字符串
else if (geometryType === "linestring") {
//console.log('afterthisis notwroling')
//let newFeatures = helper.feature(shape.geometry.coordinates)
let line = Turf.lineString(shape.geometry.coordinates); //geometry data
console.log('shape.geometry.coordinates=>>>>>>>>>>>>>>>>>>>>>>>>>', shape.geometry.coordinates)
//console.log(line)
let bbox = Turf.bbox(line) //max min longitude
console.log('bbox=>>>>>>>>>>>',bbox)
let point1 = Turf.point([bbox[0],
bbox[1]]); //max min longitute
let point2 = Turf.point([bbox[2],
bbox[3]]);
let centerFeature = Turf.midpoint(point1, point2); // finding center data
center = centerFeature.geometry.coordinates
}
/// dataset.geometry geojson.turf get center error: Error: coordinates must contain numbers