|
@@ -699,17 +699,30 @@ export default class Layer {
|
|
|
//弯路添加控制点
|
|
|
else if (e.code == "KeyT") {
|
|
|
const curveRoad = dataService.getCurveRoad(focusItem.vectorId);
|
|
|
- const joinInfo = mathUtil.getHitInfoForCurves(
|
|
|
+ let index = mathUtil.getIndexForCurvesPoints(
|
|
|
this.mousePosition,
|
|
|
- curveRoad.curves,
|
|
|
- curveRoad.width
|
|
|
- );
|
|
|
- const index = mathUtil.getIndexForCurvesPoints(
|
|
|
- joinInfo.position,
|
|
|
curveRoad.points
|
|
|
);
|
|
|
if (index != -1) {
|
|
|
curveRoadService.addCPoint(curveRoad, this.mousePosition, index);
|
|
|
+ } else {
|
|
|
+ const dis1 = mathUtil.getDistance(
|
|
|
+ curveRoad.points[0],
|
|
|
+ this.mousePosition
|
|
|
+ );
|
|
|
+ const dis2 = mathUtil.getDistance(
|
|
|
+ curveRoad.points[curveRoad.points.length - 1],
|
|
|
+ this.mousePosition
|
|
|
+ );
|
|
|
+ if (dis1 > dis2) {
|
|
|
+ curveRoadService.addCPoint(
|
|
|
+ curveRoad,
|
|
|
+ this.mousePosition,
|
|
|
+ curveRoad.points.length - 2
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ curveRoadService.addCPoint(curveRoad, this.mousePosition, 1);
|
|
|
+ }
|
|
|
}
|
|
|
this.renderer.autoRedraw();
|
|
|
this.history.save();
|