import sort_nearest_line from "./sort_point_nearest_line"; const sort_point_without_startend = function (points: number[][], isVertical: boolean) { // 寻找起始点,先按照升序排序 if (isVertical) { // 按照 lat 寻找 points.sort(function (r1, r2) { return r1[1] < r2[1] ? -1 : 1; }); } else { points.sort(function (r1, r2) { return r1[0] < r2[0] ? -1 : 1; }); } // console.log("sorted", points); // 别急,先取起始点,然后用贴近算法再排一次 const startPoint = points[0]; const endPoint = points[points.length - 1]; const result = sort_nearest_line(startPoint, endPoint, points.slice(1, points.length - 2)); result.unshift(startPoint); result.push(endPoint); // console.log("result", result); return result; }; export default sort_point_without_startend;