您好我正在尝试通过两条长/纬线画一条线来创建一个三角形。到目前为止,我已经设法画了一条直线,但线条并不垂直,看起来有些偏斜。这是我的代码:
startPosition = [-0.17640, 51.426700];
endPosition = [0.17640, 51.796700];
triangleSizeY = (endPosition [1] - startPosition[1]) / 6;
/*subtract
end from start to work out direction and also use this divided by 6 to
get distance*/
triangleSize *= -1;
triangleSizeX = (endPosition [0] - startPosition[0]) / 6;
/*subtract
end from start to work out direction and also use this divided by 6 to
get distance*/
triangleSize *= -1;
var cx = (startPosition[0] + endPosition[0]) / 2;
var cy = (startPosition[1] + endPosition[1]) / 2;
var dx = (endPosition[0] - startPosition[0]) / 2;
var dy = (endPosition[1] - startPosition[1]) / 2;
positions[0] = [midPoint[0] + triangleSizeX, midPoint[1] +
triangleSizeY];
positions[1] = [cx - dy, cy + dx];
positions[2] = [cx + dy, cy - dx];
这就是它的样子:
答案 0 :(得分:0)
首先,lat / lon是有角度的,所以你不能做线性类型的距离。您需要采取的步骤来解决这个问题:
此网站(https://www.movable-type.co.uk/scripts/latlong.html)具有您执行此操作所需的计算。此外,由于距离相对较小,您可以使用Haversine上的Equirectangular近似来计算距离。