|
@@ -137,7 +137,7 @@ export default class CurveRoadService extends RoadService {
|
|
|
rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
|
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
|
|
|
|
- for (let i = 0; i < leftCount; ++i) {
|
|
|
+ for (let i = 0; i < leftCount - 1; ++i) {
|
|
|
const leftLaneLine = mathUtil.createLine1(
|
|
|
curveRoad.leftLanes[i][startIndex],
|
|
|
curveRoad.leftLanes[i][startIndex + 1]
|
|
@@ -149,7 +149,7 @@ export default class CurveRoadService extends RoadService {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- for (let i = 0; i < rightCount; ++i) {
|
|
|
+ for (let i = 0; i < rightCount - 1; ++i) {
|
|
|
const rightLaneLine = mathUtil.createLine1(
|
|
|
curveRoad.rightLanes[i][startIndex],
|
|
|
curveRoad.rightLanes[i][startIndex + 1]
|
|
@@ -270,66 +270,17 @@ export default class CurveRoadService extends RoadService {
|
|
|
let rightLanes = [];
|
|
|
let rightLanesCurves = [];
|
|
|
|
|
|
- const len = points.length;
|
|
|
- // let leftdx1 = leftEdgePoints[0].x - points[0].x;
|
|
|
- // leftdx1 = leftdx1 / (leftCount + 1);
|
|
|
-
|
|
|
- // let leftdy1 = leftEdgePoints[0].y - points[0].y;
|
|
|
- // leftdy1 = leftdy1 / (leftCount + 1);
|
|
|
-
|
|
|
- // let leftdx2 =
|
|
|
- // leftEdgePoints[leftEdgePoints.length - 1].x - points[len - 1].x;
|
|
|
- // leftdx2 = leftdx2 / (leftCount + 1);
|
|
|
-
|
|
|
- // let leftdy2 =
|
|
|
- // leftEdgePoints[leftEdgePoints.length - 1].y - points[len - 1].y;
|
|
|
- // leftdy2 = leftdy2 / (leftCount + 1);
|
|
|
-
|
|
|
if (dir == "left" || !dir) {
|
|
|
- for (let i = 0; i < leftCount; ++i) {
|
|
|
+ for (let i = 0; i < leftCount - 1; ++i) {
|
|
|
for (let j = 0; j < points.length; ++j) {
|
|
|
if (!leftLanes[i]) {
|
|
|
leftLanes[i] = [];
|
|
|
}
|
|
|
- const leftdx = (leftEdgePoints[j].x - points[j].x) / (leftCount + 1);
|
|
|
- const leftdy = (leftEdgePoints[j].y - points[j].y) / (leftCount + 1);
|
|
|
+ const leftdx = (leftEdgePoints[j].x - points[j].x) / leftCount;
|
|
|
+ const leftdy = (leftEdgePoints[j].y - points[j].y) / leftCount;
|
|
|
leftLanes[i][j] = {};
|
|
|
leftLanes[i][j].x = points[j].x + leftdx * (i + 1);
|
|
|
leftLanes[i][j].y = points[j].y + leftdy * (i + 1);
|
|
|
- // if (j == 0) {
|
|
|
- // leftLanes[i][j].x = points[j].x + leftdx1 * (i + 1);
|
|
|
- // leftLanes[i][j].y = points[j].y + leftdy1 * (i + 1);
|
|
|
- // } else if (j == points.length - 1) {
|
|
|
- // leftLanes[i][j].x = points[j].x + leftdx2 * (i + 1);
|
|
|
- // leftLanes[i][j].y = points[j].y + leftdy2 * (i + 1);
|
|
|
- // } else {
|
|
|
- // let edgePoints1 = mathUtil.RectangleVertex(
|
|
|
- // points[j],
|
|
|
- // points[j - 1],
|
|
|
- // ((leftEdgePoints[j].x - points[j].x) / (leftCount + 1)) * (i + 1)
|
|
|
- // );
|
|
|
- // let line1 = mathUtil.createLine1(
|
|
|
- // edgePoints1.leftEdgeStart,
|
|
|
- // edgePoints1.leftEdgeEnd
|
|
|
- // );
|
|
|
-
|
|
|
- // let edgePoints2 = mathUtil.RectangleVertex(
|
|
|
- // points[j],
|
|
|
- // points[j + 1],
|
|
|
- // ((leftEdgePoints[j].x - points[j].x) / (leftCount + 1)) * (i + 1)
|
|
|
- // );
|
|
|
- // let line2 = mathUtil.createLine1(
|
|
|
- // edgePoints2.leftEdgeStart,
|
|
|
- // edgePoints2.leftEdgeEnd
|
|
|
- // );
|
|
|
-
|
|
|
- // let join = mathUtil.getIntersectionPoint(line1, line2);
|
|
|
- // if (join == null) {
|
|
|
- // join = mathUtil.getJoinLinePoint(points[j], line1);
|
|
|
- // }
|
|
|
- // leftLanes[i][j].x = join.x;
|
|
|
- // leftLanes[i][j].y = join.y;
|
|
|
- // }
|
|
|
}
|
|
|
leftLanesCurves[i] = mathUtil.getCurvesByPoints(leftLanes[i]);
|
|
|
}
|
|
@@ -337,69 +288,17 @@ export default class CurveRoadService extends RoadService {
|
|
|
curveRoad.leftLanesCurves = leftLanesCurves;
|
|
|
}
|
|
|
|
|
|
- // let rightdx1 = rightEdgePoints[0].x - points[0].x;
|
|
|
- // rightdx1 = rightdx1 / (rightCount + 1);
|
|
|
-
|
|
|
- // let rightdy1 = rightEdgePoints[0].y - points[0].y;
|
|
|
- // rightdy1 = rightdy1 / (rightCount + 1);
|
|
|
-
|
|
|
- // let rightdx2 =
|
|
|
- // rightEdgePoints[rightEdgePoints.length - 1].x - points[len - 1].x;
|
|
|
- // rightdx2 = rightdx2 / (rightCount + 1);
|
|
|
-
|
|
|
- // let rightdy2 =
|
|
|
- // rightEdgePoints[rightEdgePoints.length - 1].y - points[len - 1].y;
|
|
|
- // rightdy2 = rightdy2 / (rightCount + 1);
|
|
|
-
|
|
|
if (dir == "right" || !dir) {
|
|
|
- for (let i = 0; i < rightCount; ++i) {
|
|
|
+ for (let i = 0; i < rightCount - 1; ++i) {
|
|
|
for (let j = 0; j < points.length; ++j) {
|
|
|
if (!rightLanes[i]) {
|
|
|
rightLanes[i] = [];
|
|
|
}
|
|
|
- const rightdx =
|
|
|
- (rightEdgePoints[j].x - points[j].x) / (rightCount + 1);
|
|
|
- const rightdy =
|
|
|
- (rightEdgePoints[j].y - points[j].y) / (rightCount + 1);
|
|
|
+ const rightdx = (rightEdgePoints[j].x - points[j].x) / rightCount;
|
|
|
+ const rightdy = (rightEdgePoints[j].y - points[j].y) / rightCount;
|
|
|
rightLanes[i][j] = {};
|
|
|
rightLanes[i][j].x = points[j].x + rightdx * (i + 1);
|
|
|
rightLanes[i][j].y = points[j].y + rightdy * (i + 1);
|
|
|
- // if (j == 0) {
|
|
|
- // rightLanes[i][j].x = points[j].x + rightdx1 * (i + 1);
|
|
|
- // rightLanes[i][j].y = points[j].y + rightdy1 * (i + 1);
|
|
|
- // } else if (j == points.length - 1) {
|
|
|
- // rightLanes[i][j].x = points[j].x + rightdx2 * (i + 1);
|
|
|
- // rightLanes[i][j].y = points[j].y + rightdy2 * (i + 1);
|
|
|
- // } else {
|
|
|
- // let edgePoints1 = mathUtil.RectangleVertex(
|
|
|
- // points[j],
|
|
|
- // points[j - 1],
|
|
|
- // ((rightEdgePoints[j].x - points[j].x) / (rightCount + 1)) *
|
|
|
- // (i + 1)
|
|
|
- // );
|
|
|
- // let line1 = mathUtil.createLine1(
|
|
|
- // edgePoints1.rightEdgeStart,
|
|
|
- // edgePoints1.rightEdgeEnd
|
|
|
- // );
|
|
|
-
|
|
|
- // let edgePoints2 = mathUtil.RectangleVertex(
|
|
|
- // points[j],
|
|
|
- // points[j + 1],
|
|
|
- // ((rightEdgePoints[j].x - points[j].x) / (rightCount + 1)) *
|
|
|
- // (i + 1)
|
|
|
- // );
|
|
|
- // let line2 = mathUtil.createLine1(
|
|
|
- // edgePoints2.rightEdgeStart,
|
|
|
- // edgePoints2.rightEdgeEnd
|
|
|
- // );
|
|
|
-
|
|
|
- // let join = mathUtil.getIntersectionPoint(line1, line2);
|
|
|
- // if (join == null) {
|
|
|
- // join = mathUtil.getJoinLinePoint(points[j], line1);
|
|
|
- // }
|
|
|
- // rightLanes[i][j].x = join.x;
|
|
|
- // rightLanes[i][j].y = join.y;
|
|
|
- // }
|
|
|
}
|
|
|
rightLanesCurves[i] = mathUtil.getCurvesByPoints(rightLanes[i]);
|
|
|
}
|
|
@@ -411,6 +310,11 @@ export default class CurveRoadService extends RoadService {
|
|
|
//删除或者减少车道
|
|
|
updateForAddSubtractLanesCount(curveRoad, newCount, dir) {
|
|
|
let curveEdge, oldCount, lanes;
|
|
|
+
|
|
|
+ if (newCount < 0) {
|
|
|
+ newCount = 0;
|
|
|
+ }
|
|
|
+
|
|
|
if (dir == "left") {
|
|
|
curveEdge = dataService.getCurveEdge(curveRoad.leftEdgeId);
|
|
|
oldCount = curveRoad.leftDrivewayCount;
|
|
@@ -434,12 +338,10 @@ export default class CurveRoadService extends RoadService {
|
|
|
}
|
|
|
|
|
|
for (let i = 0; i < curveRoad.points.length; ++i) {
|
|
|
- const dx =
|
|
|
- (curveEdge.points[i].x - curveRoad.points[i].x) / (oldCount + 1);
|
|
|
- curveEdge.points[i].x = curveRoad.points[i].x + dx * (newCount + 1);
|
|
|
- const dy =
|
|
|
- (curveEdge.points[i].y - curveRoad.points[i].y) / (oldCount + 1);
|
|
|
- curveEdge.points[i].y = curveRoad.points[i].y + dy * (newCount + 1);
|
|
|
+ const dx = (curveEdge.points[i].x - curveRoad.points[i].x) / oldCount;
|
|
|
+ curveEdge.points[i].x = curveRoad.points[i].x + dx * newCount;
|
|
|
+ const dy = (curveEdge.points[i].y - curveRoad.points[i].y) / oldCount;
|
|
|
+ curveEdge.points[i].y = curveRoad.points[i].y + dy * newCount;
|
|
|
}
|
|
|
|
|
|
mathUtil.clonePoint(curveEdge.start, curveEdge.points[0]);
|
|
@@ -449,23 +351,31 @@ export default class CurveRoadService extends RoadService {
|
|
|
);
|
|
|
curveEdgeService.setCurves(curveEdge);
|
|
|
this.setLanes(curveRoad, dir);
|
|
|
+
|
|
|
+ const line = mathUtil.createLine1(curveRoad.points[0], curveRoad.points[1]);
|
|
|
+ const leftCurveEdge = dataService.getCurveEdge(curveRoad.leftEdgeId);
|
|
|
+ const rightCurveEdge = dataService.getCurveEdge(curveRoad.leftEdgeId);
|
|
|
+ const leftWidth = mathUtil.getDisForPoinLine(leftCurveEdge.start, line);
|
|
|
+ const rightWidth = mathUtil.getDisForPoinLine(rightCurveEdge.start, line);
|
|
|
+ curveRoad.setWidth(leftWidth + rightWidth);
|
|
|
}
|
|
|
|
|
|
//单车道转多车道,默认是转换成左右两边各一个
|
|
|
//不改变路的宽度
|
|
|
singleToMullane(curveRoad) {
|
|
|
- curveRoad.rightEdgeId = null;
|
|
|
curveRoad.leftDrivewayCount = 1;
|
|
|
curveRoad.rightDrivewayCount = 1;
|
|
|
- let lanes = this.setLanes(curveRoad);
|
|
|
- curveRoad.leftLanes = lanes.leftLanes;
|
|
|
- curveRoad.rightLanes = lanes.rightLanes;
|
|
|
- curveRoad.leftLanesCurves = lanes.leftLanesCurves;
|
|
|
- curveRoad.rightLanesCurves = lanes.rightLanesCurves;
|
|
|
+ this.setLanes(curveRoad);
|
|
|
}
|
|
|
|
|
|
//多车道转单车道
|
|
|
mulToSinglelane(curveRoad) {
|
|
|
+ if (curveRoad.leftDrivewayCount > 0) {
|
|
|
+ this.updateForAddSubtractLanesCount(curveRoad, 1, "left");
|
|
|
+ }
|
|
|
+ if (curveRoad.rightDrivewayCount > 0) {
|
|
|
+ this.updateForAddSubtractLanesCount(curveRoad, 1, "right");
|
|
|
+ }
|
|
|
curveRoad.leftDrivewayCount = 0;
|
|
|
curveRoad.rightDrivewayCount = 0;
|
|
|
curveRoad.leftLanesCurves = [];
|
|
@@ -492,13 +402,65 @@ export default class CurveRoadService extends RoadService {
|
|
|
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;
|
|
|
- curveRoad.leftLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
- curveRoad.leftLanes[i]
|
|
|
- );
|
|
|
-
|
|
|
//需要修改端点
|
|
|
if (
|
|
|
index == 0 ||
|
|
@@ -507,39 +469,47 @@ export default class CurveRoadService extends RoadService {
|
|
|
index == curveRoad.points.length - 2
|
|
|
) {
|
|
|
if (index == 0 || index == 1) {
|
|
|
- line = mathUtil.createLine1(
|
|
|
- curveRoad.leftLanes[i][0],
|
|
|
- curveRoad.leftLanes[i][1]
|
|
|
- );
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
|
|
|
- curveRoad.leftLanes[i][0].x = join.x;
|
|
|
- curveRoad.leftLanes[i][0].y = join.y;
|
|
|
+ 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.leftLanes[i][len - 2],
|
|
|
- curveRoad.leftLanes[i][len - 1]
|
|
|
+ curveRoad.points[len - 2],
|
|
|
+ curveRoad.points[len - 1]
|
|
|
);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
|
|
|
- curveRoad.leftLanes[i][len - 1].x = join.x;
|
|
|
- curveRoad.leftLanes[i][len - 1].y = join.y;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- const rightCurveEdge = dataService.getCurveEdge(curveRoad.rightEdgeId);
|
|
|
- rightCurveEdge.points[index].x += dx;
|
|
|
- rightCurveEdge.points[index].y += dy;
|
|
|
+ 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;
|
|
|
- curveRoad.rightLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
- curveRoad.rightLanes[i]
|
|
|
- );
|
|
|
-
|
|
|
//需要修改端点
|
|
|
if (
|
|
|
index == 0 ||
|
|
@@ -548,66 +518,42 @@ export default class CurveRoadService extends RoadService {
|
|
|
index == curveRoad.points.length - 2
|
|
|
) {
|
|
|
if (index == 0 || index == 1) {
|
|
|
- line = mathUtil.createLine1(
|
|
|
- curveRoad.rightLanes[i][0],
|
|
|
- curveRoad.rightLanes[i][1]
|
|
|
- );
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
|
|
|
- curveRoad.rightLanes[i][0].x = join.x;
|
|
|
- curveRoad.rightLanes[i][0].y = join.y;
|
|
|
+ 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.rightLanes[i][len - 2],
|
|
|
- curveRoad.rightLanes[i][len - 1]
|
|
|
+ curveRoad.points[len - 2],
|
|
|
+ curveRoad.points[len - 1]
|
|
|
);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
|
|
|
- curveRoad.rightLanes[i][len - 1].x = join.x;
|
|
|
- curveRoad.rightLanes[i][len - 1].y = join.y;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if (index == 0 || index == 1) {
|
|
|
- line = mathUtil.createLine1(
|
|
|
- leftCurveEdge.points[0],
|
|
|
- leftCurveEdge.points[1]
|
|
|
- );
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
|
|
|
- leftCurveEdge.points[0].x = join.x;
|
|
|
- leftCurveEdge.points[0].y = join.y;
|
|
|
|
|
|
- line = mathUtil.createLine1(
|
|
|
- rightCurveEdge.points[0],
|
|
|
- rightCurveEdge.points[1]
|
|
|
- );
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
|
|
|
- rightCurveEdge.points[0].x = join.x;
|
|
|
- rightCurveEdge.points[0].y = join.y;
|
|
|
- }
|
|
|
-
|
|
|
- if (
|
|
|
- index == curveRoad.points.length - 1 ||
|
|
|
- index == curveRoad.points.length - 2
|
|
|
- ) {
|
|
|
- line = mathUtil.createLine1(
|
|
|
- leftCurveEdge.points[len - 2],
|
|
|
- leftCurveEdge.points[len - 1]
|
|
|
- );
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
|
|
|
- leftCurveEdge.points[len - 1].x = join.x;
|
|
|
- leftCurveEdge.points[len - 1].y = join.y;
|
|
|
-
|
|
|
- line = mathUtil.createLine1(
|
|
|
- rightCurveEdge.points[len - 2],
|
|
|
- rightCurveEdge.points[len - 1]
|
|
|
+ curveRoad.rightLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
+ curveRoad.rightLanes[i]
|
|
|
);
|
|
|
- join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
|
|
|
- rightCurveEdge.points[len - 1].x = join.x;
|
|
|
- rightCurveEdge.points[len - 1].y = join.y;
|
|
|
}
|
|
|
|
|
|
this.setCurves(curveRoad);
|
|
@@ -618,115 +564,6 @@ export default class CurveRoadService extends RoadService {
|
|
|
setCurves(curveRoad) {
|
|
|
curveRoad.curves = mathUtil.getCurvesByPoints(curveRoad.points);
|
|
|
}
|
|
|
-
|
|
|
- // updateForMovePoint(curveRoad, index) {
|
|
|
- // let points = curveRoad.points;
|
|
|
- // let leftEdge = dataService.getCurveEdge(curveRoad.leftEdgeId);
|
|
|
- // let rightEdge = dataService.getCurveEdge(curveRoad.rightEdgeId);
|
|
|
- // let leftEdgePoints = leftEdge.points;
|
|
|
- // let rightEdgePoints = rightEdge.points;
|
|
|
- // let leftCount = curveRoad.leftDrivewayCount;
|
|
|
- // let rightCount = curveRoad.rightDrivewayCount;
|
|
|
-
|
|
|
- // const len = points.length;
|
|
|
- // let leftdx1 = leftEdgePoints[0].x - points[0].x;
|
|
|
- // leftdx1 = leftdx1 / leftCount;
|
|
|
-
|
|
|
- // let leftdy1 = leftEdgePoints[0].y - points[0].y;
|
|
|
- // leftdy1 = leftdy1 / leftCount;
|
|
|
-
|
|
|
- // let leftdx2 = leftEdgePoints[len - 1].x - points[len - 1].x;
|
|
|
- // leftdx2 = leftdx2 / leftCount;
|
|
|
-
|
|
|
- // let leftdy2 = leftEdgePoints[len - 1].y - points[len - 1].y;
|
|
|
- // leftdy2 = leftdy2 / leftCount;
|
|
|
-
|
|
|
- // for (let i = 0; i < leftCount - 1; ++i) {
|
|
|
- // if (index == 0) {
|
|
|
- // curveRoad.leftLanes[i][index].x = points[index].x + leftdx1 * (i + 1);
|
|
|
- // curveRoad.leftLanes[i][index].y = points[index].y + leftdy1 * (i + 1);
|
|
|
- // } else if (index == points.length - 1) {
|
|
|
- // curveRoad.leftLanes[i][index].x = points[index].x + leftdx2 * (i + 1);
|
|
|
- // curveRoad.leftLanes[i][index].y = points[index].y + leftdy2 * (i + 1);
|
|
|
- // } else {
|
|
|
- // let edgePoints1 = mathUtil.RectangleVertex(
|
|
|
- // points[index],
|
|
|
- // points[index - 1],
|
|
|
- // leftdx1
|
|
|
- // );
|
|
|
- // let line1 = mathUtil.createLine1(
|
|
|
- // edgePoints1.leftEdgeStart,
|
|
|
- // edgePoints1.leftEdgeEnd
|
|
|
- // );
|
|
|
-
|
|
|
- // let edgePoints2 = mathUtil.RectangleVertex(
|
|
|
- // points[index],
|
|
|
- // points[index + 1],
|
|
|
- // leftdx1
|
|
|
- // );
|
|
|
- // let line2 = mathUtil.createLine1(
|
|
|
- // edgePoints2.leftEdgeStart,
|
|
|
- // edgePoints2.leftEdgeEnd
|
|
|
- // );
|
|
|
-
|
|
|
- // let join = mathUtil.getIntersectionPoint(line1, line2);
|
|
|
- // if (join == null) {
|
|
|
- // join = mathUtil.getLineForPoint(line1, points[index]);
|
|
|
- // }
|
|
|
- // curveRoad.leftLanes[i][index].x = join.x;
|
|
|
- // curveRoad.leftLanes[i][index].y = join.y;
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // let rightdx1 = rightEdgePoints[0].x - points[0].x;
|
|
|
- // rightdx1 = rightdx1 / rightCount;
|
|
|
-
|
|
|
- // let rightdy1 = rightEdgePoints[0].y - points[0].y;
|
|
|
- // rightdy1 = rightdy1 / rightCount;
|
|
|
-
|
|
|
- // let rightdx2 = rightEdgePoints[len - 1].x - points[len - 1].x;
|
|
|
- // rightdx2 = rightdx2 / rightCount;
|
|
|
-
|
|
|
- // let rightdy2 = rightEdgePoints[len - 1].y - points[len - 1].y;
|
|
|
- // rightdy2 = rightdy2 / rightCount;
|
|
|
-
|
|
|
- // for (let i = 0; i < rightCount - 1; ++i) {
|
|
|
- // if (index == 0) {
|
|
|
- // curveRoad.rightLanes[i][index].x = points[index].x + rightdx1 * (i + 1);
|
|
|
- // curveRoad.rightLanes[i][index].y = points[index].y + rightdy1 * (i + 1);
|
|
|
- // } else if (index == points.length - 1) {
|
|
|
- // curveRoad.rightLanes[i][index].x = points[index].x + rightdy2 * (i + 1);
|
|
|
- // curveRoad.rightLanes[i][index].y = points[index].y + rightdy2 * (i + 1);
|
|
|
- // } else {
|
|
|
- // let edgePoints1 = mathUtil.RectangleVertex(
|
|
|
- // points[index],
|
|
|
- // points[index - 1],
|
|
|
- // rightdx1
|
|
|
- // );
|
|
|
- // let line1 = mathUtil.createLine1(
|
|
|
- // edgePoints1.rightEdgeStart,
|
|
|
- // edgePoints1.rightEdgeEnd
|
|
|
- // );
|
|
|
-
|
|
|
- // let edgePoints2 = mathUtil.RectangleVertex(
|
|
|
- // points[index],
|
|
|
- // points[index + 1],
|
|
|
- // rightdx1
|
|
|
- // );
|
|
|
- // let line2 = mathUtil.createLine1(
|
|
|
- // edgePoints2.rightEdgeStart,
|
|
|
- // edgePoints2.rightEdgeEnd
|
|
|
- // );
|
|
|
-
|
|
|
- // let join = mathUtil.getIntersectionPoint(line1, line2);
|
|
|
- // if (join == null) {
|
|
|
- // join = mathUtil.getLineForPoint(line1, points[index]);
|
|
|
- // }
|
|
|
- // curveRoad.rightLanes[i][index].x = join.x;
|
|
|
- // curveRoad.rightLanes[i][index].y = join.y;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
const curveRoadService = new CurveRoadService();
|