1.分别找经纬度的最大最小值,然后再取平均做为ThreeJs坐标系中原点坐标basePoint
2.将拿到的路径中的点都与原点相减得到其在ThreeJs中的坐标
/**
* 生成基准点坐标
*/
function createBasePoint(data) {
let x_min = 0;
let x_max = 0;
let y_min = 0;
let y_max = 0;
// let z_min = 0;
// let z_max = 0;
let x;
let y;
// let z;
let first = true;
data.forEach(function (item) {
let arr = item.split(' ');
// t = parseFloat(arr[1]);
// x = parseFloat(arr[1]) * 10;
// y = parseFloat(arr[2]) * 10;
x = Number(arr[1]);
y = Number(arr[2]);
// z = 10;
if (first) {
x_min = x_max = x;
y_min = y_max = y;
// z_min = z_max = z;
first = false;
}
else {
if (x_min > x) {
x_min = x;
}
if (x_max < x) {
x_max = x;
}
if (y_min > y) {
y_min = y;
}
if (y_max < y) {
y_max = y;
}
// if (z_min > z) z_min = z;
// if (z_max < z) z_max = z;
}
});
let x_half = (x_max + x_min) * Math.pow(10, 6) / 2;
let y_half = (y_min + y_max) * Math.pow(10, 6) / 2;
setBasePoint(x_half, y_half);
}
网友评论