从两个地理位置坐标点创建一个框

时间:2016-12-27 01:38:36

标签: java ios node.js google-maps geospatial

enter image description here

我有两个地理坐标CLLocationCoordinate2D点(P1和P2),我想创建一个与连接它们的线垂直的框(红色框)。

如何获得限制此框的四个坐标?

1 个答案:

答案 0 :(得分:2)

感谢@iant,我已经能够使用turf生成边界框(实际上是多边形)。这是我使用的代码:

turf = require("turf")

var line = turf.lineString([
[-122.1381719, 37.4687134],
[-122.0300914, 37.331695]
]);

var unit = 'miles';
var buffered = turf.buffer(line, 5, unit);
var tolerance = 0.03; // increase tolerance to reduce polygon segments
var simplified = turf.simplify(buffered, tolerance, false);

enter image description here