|
@@ -402,181 +402,216 @@ export default class CurveRoadService extends RoadService {
|
|
|
curveRoad.rightLanes = [];
|
|
|
}
|
|
|
|
|
|
+ // updateForMovePoint(pointId, position) {
|
|
|
+ // let curvePoint = dataService.getCurvePoint(pointId);
|
|
|
+ // let curveRoadId = curvePoint.getParent();
|
|
|
+ // let curveRoad = dataService.getCurveRoad(curveRoadId);
|
|
|
+
|
|
|
+ // let index = curvePoint.getIndex();
|
|
|
+ // let dx = position.x - curvePoint.x;
|
|
|
+ // let dy = position.y - curvePoint.y;
|
|
|
+
|
|
|
+ // curvePoint.setPosition(position);
|
|
|
+
|
|
|
+ // let line = null;
|
|
|
+ // let join = null;
|
|
|
+ // let len = curveRoad.points.length;
|
|
|
+
|
|
|
+ // const leftCurveEdge = dataService.getCurveEdge(curveRoad.leftEdgeId);
|
|
|
+ // leftCurveEdge.points[index].x += dx;
|
|
|
+ // leftCurveEdge.points[index].y += dy;
|
|
|
+
|
|
|
+ // const rightCurveEdge = dataService.getCurveEdge(curveRoad.rightEdgeId);
|
|
|
+ // rightCurveEdge.points[index].x += dx;
|
|
|
+ // rightCurveEdge.points[index].y += dy;
|
|
|
+
|
|
|
+ // if (index == 0 || index == 1) {
|
|
|
+ // line = mathUtil.createLine1(curveRoad.points[0], curveRoad.points[1]);
|
|
|
+ // if (
|
|
|
+ // line != null &&
|
|
|
+ // !line.hasOwnProperty("x") &&
|
|
|
+ // !line.hasOwnProperty("y")
|
|
|
+ // ) {
|
|
|
+ // let line1 = mathUtil.createLine3(line, leftCurveEdge.points[index]);
|
|
|
+ // join = mathUtil.getJoinLinePoint(curveRoad.points[0], line1);
|
|
|
+ // leftCurveEdge.points[0].x = join.x;
|
|
|
+ // leftCurveEdge.points[0].y = join.y;
|
|
|
+ // leftCurveEdge.start.x = join.x;
|
|
|
+ // leftCurveEdge.start.y = join.y;
|
|
|
+
|
|
|
+ // let line2 = mathUtil.createLine3(line, rightCurveEdge.points[index]);
|
|
|
+ // join = mathUtil.getJoinLinePoint(curveRoad.points[0], line2);
|
|
|
+ // rightCurveEdge.points[0].x = join.x;
|
|
|
+ // rightCurveEdge.points[0].y = join.y;
|
|
|
+ // rightCurveEdge.start.x = join.x;
|
|
|
+ // rightCurveEdge.start.y = join.y;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (
|
|
|
+ // index == curveRoad.points.length - 1 ||
|
|
|
+ // index == curveRoad.points.length - 2
|
|
|
+ // ) {
|
|
|
+ // line = mathUtil.createLine1(
|
|
|
+ // curveRoad.points[len - 2],
|
|
|
+ // curveRoad.points[len - 1]
|
|
|
+ // );
|
|
|
+ // if (
|
|
|
+ // line != null &&
|
|
|
+ // !line.hasOwnProperty("x") &&
|
|
|
+ // !line.hasOwnProperty("y")
|
|
|
+ // ) {
|
|
|
+ // let line1 = mathUtil.createLine3(line, leftCurveEdge.points[index]);
|
|
|
+ // join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line1);
|
|
|
+ // leftCurveEdge.points[len - 1].x = join.x;
|
|
|
+ // leftCurveEdge.points[len - 1].y = join.y;
|
|
|
+ // leftCurveEdge.end.x = join.x;
|
|
|
+ // leftCurveEdge.end.y = join.y;
|
|
|
+ // let line2 = mathUtil.createLine3(line, rightCurveEdge.points[index]);
|
|
|
+ // join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line2);
|
|
|
+ // rightCurveEdge.points[len - 1].x = join.x;
|
|
|
+ // rightCurveEdge.points[len - 1].y = join.y;
|
|
|
+ // rightCurveEdge.end.x = join.x;
|
|
|
+ // rightCurveEdge.end.y = join.y;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // for (let i = 0; i < curveRoad.leftLanes.length; ++i) {
|
|
|
+ // curveRoad.leftLanes[i][index].x += dx;
|
|
|
+ // curveRoad.leftLanes[i][index].y += dy;
|
|
|
+ // //需要修改端点
|
|
|
+ // if (
|
|
|
+ // index == 0 ||
|
|
|
+ // index == 1 ||
|
|
|
+ // index == curveRoad.points.length - 1 ||
|
|
|
+ // index == curveRoad.points.length - 2
|
|
|
+ // ) {
|
|
|
+ // if (index == 0 || index == 1) {
|
|
|
+ // line = mathUtil.createLine1(curveRoad.points[0], curveRoad.points[1]);
|
|
|
+ // if (
|
|
|
+ // line != null &&
|
|
|
+ // !line.hasOwnProperty("x") &&
|
|
|
+ // !line.hasOwnProperty("y")
|
|
|
+ // ) {
|
|
|
+ // line = mathUtil.createLine3(line, curveRoad.leftLanes[i][index]);
|
|
|
+ // join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
|
|
|
+ // curveRoad.leftLanes[i][0].x = join.x;
|
|
|
+ // curveRoad.leftLanes[i][0].y = join.y;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (
|
|
|
+ // index == curveRoad.points.length - 1 ||
|
|
|
+ // index == curveRoad.points.length - 2
|
|
|
+ // ) {
|
|
|
+ // line = mathUtil.createLine1(
|
|
|
+ // curveRoad.points[len - 2],
|
|
|
+ // curveRoad.points[len - 1]
|
|
|
+ // );
|
|
|
+ // if (
|
|
|
+ // line != null &&
|
|
|
+ // !line.hasOwnProperty("x") &&
|
|
|
+ // !line.hasOwnProperty("y")
|
|
|
+ // ) {
|
|
|
+ // line = mathUtil.createLine3(line, curveRoad.leftLanes[i][index]);
|
|
|
+ // join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
|
|
|
+ // curveRoad.leftLanes[i][len - 1].x = join.x;
|
|
|
+ // curveRoad.leftLanes[i][len - 1].y = join.y;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // curveRoad.leftLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
+ // curveRoad.leftLanes[i]
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // for (let i = 0; i < curveRoad.rightLanes.length; ++i) {
|
|
|
+ // curveRoad.rightLanes[i][index].x += dx;
|
|
|
+ // curveRoad.rightLanes[i][index].y += dy;
|
|
|
+ // //需要修改端点
|
|
|
+ // if (
|
|
|
+ // index == 0 ||
|
|
|
+ // index == 1 ||
|
|
|
+ // index == curveRoad.points.length - 1 ||
|
|
|
+ // index == curveRoad.points.length - 2
|
|
|
+ // ) {
|
|
|
+ // if (index == 0 || index == 1) {
|
|
|
+ // line = mathUtil.createLine1(curveRoad.points[0], curveRoad.points[1]);
|
|
|
+ // if (
|
|
|
+ // line != null &&
|
|
|
+ // !line.hasOwnProperty("x") &&
|
|
|
+ // !line.hasOwnProperty("y")
|
|
|
+ // ) {
|
|
|
+ // line = mathUtil.createLine3(line, curveRoad.rightLanes[i][index]);
|
|
|
+ // join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
|
|
|
+ // curveRoad.rightLanes[i][0].x = join.x;
|
|
|
+ // curveRoad.rightLanes[i][0].y = join.y;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (
|
|
|
+ // index == curveRoad.points.length - 1 ||
|
|
|
+ // index == curveRoad.points.length - 2
|
|
|
+ // ) {
|
|
|
+ // line = mathUtil.createLine1(
|
|
|
+ // curveRoad.points[len - 2],
|
|
|
+ // curveRoad.points[len - 1]
|
|
|
+ // );
|
|
|
+ // if (
|
|
|
+ // line != null &&
|
|
|
+ // !line.hasOwnProperty("x") &&
|
|
|
+ // !line.hasOwnProperty("y")
|
|
|
+ // ) {
|
|
|
+ // line = mathUtil.createLine3(line, curveRoad.rightLanes[i][index]);
|
|
|
+ // join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
|
|
|
+ // curveRoad.rightLanes[i][len - 1].x = join.x;
|
|
|
+ // curveRoad.rightLanes[i][len - 1].y = join.y;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // curveRoad.rightLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
+ // curveRoad.rightLanes[i]
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+
|
|
|
+ // this.setCurves(curveRoad);
|
|
|
+ // curveEdgeService.setCurves(leftCurveEdge);
|
|
|
+ // curveEdgeService.setCurves(rightCurveEdge);
|
|
|
+ // }
|
|
|
+
|
|
|
updateForMovePoint(pointId, position) {
|
|
|
let curvePoint = dataService.getCurvePoint(pointId);
|
|
|
let curveRoadId = curvePoint.getParent();
|
|
|
let curveRoad = dataService.getCurveRoad(curveRoadId);
|
|
|
-
|
|
|
+ let startPoint = dataService.getCurvePoint(curveRoad.startId);
|
|
|
+ let endPoint = dataService.getCurvePoint(curveRoad.endId);
|
|
|
let index = curvePoint.getIndex();
|
|
|
- let dx = position.x - curvePoint.x;
|
|
|
- let dy = position.y - curvePoint.y;
|
|
|
-
|
|
|
- curvePoint.setPosition(position);
|
|
|
-
|
|
|
- let line = null;
|
|
|
- let join = null;
|
|
|
- let len = curveRoad.points.length;
|
|
|
+ mathUtil.clonePoint(curveRoad.points[index], position);
|
|
|
+ if (index == 0) {
|
|
|
+ mathUtil.clonePoint(startPoint, position);
|
|
|
+ } else if (index == curveRoad.points.length - 1) {
|
|
|
+ mathUtil.clonePoint(endPoint, position);
|
|
|
+ }
|
|
|
+ const edgePoints = mathUtil.getOffset(
|
|
|
+ curveRoad.points,
|
|
|
+ curveRoad.leftWidth,
|
|
|
+ curveRoad.rightWidth
|
|
|
+ );
|
|
|
|
|
|
const leftCurveEdge = dataService.getCurveEdge(curveRoad.leftEdgeId);
|
|
|
- leftCurveEdge.points[index].x += dx;
|
|
|
- leftCurveEdge.points[index].y += dy;
|
|
|
-
|
|
|
+ leftCurveEdge.points = edgePoints.leftEdgePoints;
|
|
|
+ leftCurveEdge.start = leftCurveEdge.points[0];
|
|
|
+ leftCurveEdge.end = leftCurveEdge.points[leftCurveEdge.points.length - 1];
|
|
|
const rightCurveEdge = dataService.getCurveEdge(curveRoad.rightEdgeId);
|
|
|
- rightCurveEdge.points[index].x += dx;
|
|
|
- rightCurveEdge.points[index].y += dy;
|
|
|
-
|
|
|
- if (index == 0 || index == 1) {
|
|
|
- line = mathUtil.createLine1(curveRoad.points[0], curveRoad.points[1]);
|
|
|
- if (
|
|
|
- line != null &&
|
|
|
- !line.hasOwnProperty("x") &&
|
|
|
- !line.hasOwnProperty("y")
|
|
|
- ) {
|
|
|
- let line1 = mathUtil.createLine3(line, leftCurveEdge.points[index]);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[0], line1);
|
|
|
- leftCurveEdge.points[0].x = join.x;
|
|
|
- leftCurveEdge.points[0].y = join.y;
|
|
|
- leftCurveEdge.start.x = join.x;
|
|
|
- leftCurveEdge.start.y = join.y;
|
|
|
-
|
|
|
- let line2 = mathUtil.createLine3(line, rightCurveEdge.points[index]);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[0], line2);
|
|
|
- rightCurveEdge.points[0].x = join.x;
|
|
|
- rightCurveEdge.points[0].y = join.y;
|
|
|
- rightCurveEdge.start.x = join.x;
|
|
|
- rightCurveEdge.start.y = join.y;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (
|
|
|
- index == curveRoad.points.length - 1 ||
|
|
|
- index == curveRoad.points.length - 2
|
|
|
- ) {
|
|
|
- line = mathUtil.createLine1(
|
|
|
- curveRoad.points[len - 2],
|
|
|
- curveRoad.points[len - 1]
|
|
|
- );
|
|
|
- if (
|
|
|
- line != null &&
|
|
|
- !line.hasOwnProperty("x") &&
|
|
|
- !line.hasOwnProperty("y")
|
|
|
- ) {
|
|
|
- let line1 = mathUtil.createLine3(line, leftCurveEdge.points[index]);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line1);
|
|
|
- leftCurveEdge.points[len - 1].x = join.x;
|
|
|
- leftCurveEdge.points[len - 1].y = join.y;
|
|
|
- leftCurveEdge.end.x = join.x;
|
|
|
- leftCurveEdge.end.y = join.y;
|
|
|
- let line2 = mathUtil.createLine3(line, rightCurveEdge.points[index]);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line2);
|
|
|
- rightCurveEdge.points[len - 1].x = join.x;
|
|
|
- rightCurveEdge.points[len - 1].y = join.y;
|
|
|
- rightCurveEdge.end.x = join.x;
|
|
|
- rightCurveEdge.end.y = join.y;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (let i = 0; i < curveRoad.leftLanes.length; ++i) {
|
|
|
- curveRoad.leftLanes[i][index].x += dx;
|
|
|
- curveRoad.leftLanes[i][index].y += dy;
|
|
|
- //需要修改端点
|
|
|
- if (
|
|
|
- index == 0 ||
|
|
|
- index == 1 ||
|
|
|
- index == curveRoad.points.length - 1 ||
|
|
|
- index == curveRoad.points.length - 2
|
|
|
- ) {
|
|
|
- if (index == 0 || index == 1) {
|
|
|
- line = mathUtil.createLine1(curveRoad.points[0], curveRoad.points[1]);
|
|
|
- if (
|
|
|
- line != null &&
|
|
|
- !line.hasOwnProperty("x") &&
|
|
|
- !line.hasOwnProperty("y")
|
|
|
- ) {
|
|
|
- line = mathUtil.createLine3(line, curveRoad.leftLanes[i][index]);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
|
|
|
- curveRoad.leftLanes[i][0].x = join.x;
|
|
|
- curveRoad.leftLanes[i][0].y = join.y;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (
|
|
|
- index == curveRoad.points.length - 1 ||
|
|
|
- index == curveRoad.points.length - 2
|
|
|
- ) {
|
|
|
- line = mathUtil.createLine1(
|
|
|
- curveRoad.points[len - 2],
|
|
|
- curveRoad.points[len - 1]
|
|
|
- );
|
|
|
- if (
|
|
|
- line != null &&
|
|
|
- !line.hasOwnProperty("x") &&
|
|
|
- !line.hasOwnProperty("y")
|
|
|
- ) {
|
|
|
- line = mathUtil.createLine3(line, curveRoad.leftLanes[i][index]);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
|
|
|
- curveRoad.leftLanes[i][len - 1].x = join.x;
|
|
|
- curveRoad.leftLanes[i][len - 1].y = join.y;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ rightCurveEdge.points = edgePoints.rightEdgePoints;
|
|
|
+ rightCurveEdge.start = rightCurveEdge.points[0];
|
|
|
+ rightCurveEdge.end =
|
|
|
+ rightCurveEdge.points[rightCurveEdge.points.length - 1];
|
|
|
|
|
|
- curveRoad.leftLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
- curveRoad.leftLanes[i]
|
|
|
- );
|
|
|
- }
|
|
|
- for (let i = 0; i < curveRoad.rightLanes.length; ++i) {
|
|
|
- curveRoad.rightLanes[i][index].x += dx;
|
|
|
- curveRoad.rightLanes[i][index].y += dy;
|
|
|
- //需要修改端点
|
|
|
- if (
|
|
|
- index == 0 ||
|
|
|
- index == 1 ||
|
|
|
- index == curveRoad.points.length - 1 ||
|
|
|
- index == curveRoad.points.length - 2
|
|
|
- ) {
|
|
|
- if (index == 0 || index == 1) {
|
|
|
- line = mathUtil.createLine1(curveRoad.points[0], curveRoad.points[1]);
|
|
|
- if (
|
|
|
- line != null &&
|
|
|
- !line.hasOwnProperty("x") &&
|
|
|
- !line.hasOwnProperty("y")
|
|
|
- ) {
|
|
|
- line = mathUtil.createLine3(line, curveRoad.rightLanes[i][index]);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
|
|
|
- curveRoad.rightLanes[i][0].x = join.x;
|
|
|
- curveRoad.rightLanes[i][0].y = join.y;
|
|
|
- }
|
|
|
- }
|
|
|
- if (
|
|
|
- index == curveRoad.points.length - 1 ||
|
|
|
- index == curveRoad.points.length - 2
|
|
|
- ) {
|
|
|
- line = mathUtil.createLine1(
|
|
|
- curveRoad.points[len - 2],
|
|
|
- curveRoad.points[len - 1]
|
|
|
- );
|
|
|
- if (
|
|
|
- line != null &&
|
|
|
- !line.hasOwnProperty("x") &&
|
|
|
- !line.hasOwnProperty("y")
|
|
|
- ) {
|
|
|
- line = mathUtil.createLine3(line, curveRoad.rightLanes[i][index]);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
|
|
|
- curveRoad.rightLanes[i][len - 1].x = join.x;
|
|
|
- curveRoad.rightLanes[i][len - 1].y = join.y;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- curveRoad.rightLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
- curveRoad.rightLanes[i]
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- this.setCurves(curveRoad);
|
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
|
+ this.setCurves(curveRoad);
|
|
|
+ this.setLanes(curveRoad);
|
|
|
}
|
|
|
|
|
|
//变宽或者变窄(车道数据不变)
|