|
@@ -30,34 +30,14 @@ export default class CurveRoadService extends RoadService {
|
|
|
|
|
|
let edgePoints;
|
|
let edgePoints;
|
|
if (curveRoad.way == Constant.oneWay) {
|
|
if (curveRoad.way == Constant.oneWay) {
|
|
- edgePoints = mathUtil.RectangleVertex(
|
|
|
|
- startPoint,
|
|
|
|
- endPoint,
|
|
|
|
- curveRoad.singleRoadWidth
|
|
|
|
- );
|
|
|
|
|
|
+ edgePoints = mathUtil.RectangleVertex(startPoint, endPoint, curveRoad.singleRoadWidth);
|
|
} else {
|
|
} else {
|
|
- edgePoints = mathUtil.RectangleVertex(
|
|
|
|
- startPoint,
|
|
|
|
- endPoint,
|
|
|
|
- curveRoad.leftWidth +
|
|
|
|
- curveRoad.rightWidth +
|
|
|
|
- curveRoad.midDivide.midDivideWidth
|
|
|
|
- );
|
|
|
|
|
|
+ edgePoints = mathUtil.RectangleVertex(startPoint, endPoint, curveRoad.leftWidth + curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth);
|
|
}
|
|
}
|
|
|
|
|
|
- let leftEdge = curveEdgeService.create(
|
|
|
|
- edgePoints.leftEdgeStart,
|
|
|
|
- edgePoints.leftEdgeEnd,
|
|
|
|
- null,
|
|
|
|
- vectorId
|
|
|
|
- );
|
|
|
|
|
|
+ let leftEdge = curveEdgeService.create(edgePoints.leftEdgeStart, edgePoints.leftEdgeEnd, null, vectorId);
|
|
|
|
|
|
- let rightEdge = curveEdgeService.create(
|
|
|
|
- edgePoints.rightEdgeStart,
|
|
|
|
- edgePoints.rightEdgeEnd,
|
|
|
|
- null,
|
|
|
|
- vectorId
|
|
|
|
- );
|
|
|
|
|
|
+ let rightEdge = curveEdgeService.create(edgePoints.rightEdgeStart, edgePoints.rightEdgeEnd, null, vectorId);
|
|
|
|
|
|
curveRoad.setLeftEdge(leftEdge.vectorId);
|
|
curveRoad.setLeftEdge(leftEdge.vectorId);
|
|
curveRoad.setRightEdge(rightEdge.vectorId);
|
|
curveRoad.setRightEdge(rightEdge.vectorId);
|
|
@@ -86,6 +66,7 @@ export default class CurveRoadService extends RoadService {
|
|
|
|
|
|
this.addCPoint(curveRoad, join, 1);
|
|
this.addCPoint(curveRoad, join, 1);
|
|
this.setLanes(curveRoad.vectorId);
|
|
this.setLanes(curveRoad.vectorId);
|
|
|
|
+ // this.initCurveRoadWidthTipsPos(curveRoad)
|
|
return curveRoad;
|
|
return curveRoad;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -112,10 +93,7 @@ export default class CurveRoadService extends RoadService {
|
|
let newEndPoint = uiService.getNewPositionForPop(endPoint);
|
|
let newEndPoint = uiService.getNewPositionForPop(endPoint);
|
|
newEndPoint = curveRoadPointService.create(newEndPoint);
|
|
newEndPoint = curveRoadPointService.create(newEndPoint);
|
|
|
|
|
|
- let newCurveRoad = new CurveRoad(
|
|
|
|
- newStartPoint.vectorId,
|
|
|
|
- newEndPoint.vectorId
|
|
|
|
- );
|
|
|
|
|
|
+ let newCurveRoad = new CurveRoad(newStartPoint.vectorId, newEndPoint.vectorId);
|
|
dataService.addCurveRoad(newCurveRoad);
|
|
dataService.addCurveRoad(newCurveRoad);
|
|
|
|
|
|
newStartPoint.setPointParent(newCurveRoad.vectorId);
|
|
newStartPoint.setPointParent(newCurveRoad.vectorId);
|
|
@@ -128,34 +106,14 @@ export default class CurveRoadService extends RoadService {
|
|
|
|
|
|
let edgePoints;
|
|
let edgePoints;
|
|
if (newCurveRoad.way == Constant.oneWay) {
|
|
if (newCurveRoad.way == Constant.oneWay) {
|
|
- edgePoints = mathUtil.RectangleVertex(
|
|
|
|
- newStartPoint,
|
|
|
|
- newEndPoint,
|
|
|
|
- curveRoad.singleRoadWidth
|
|
|
|
- );
|
|
|
|
|
|
+ edgePoints = mathUtil.RectangleVertex(newStartPoint, newEndPoint, curveRoad.singleRoadWidth);
|
|
} else {
|
|
} else {
|
|
- edgePoints = mathUtil.RectangleVertex(
|
|
|
|
- newStartPoint,
|
|
|
|
- newEndPoint,
|
|
|
|
- curveRoad.leftWidth +
|
|
|
|
- curveRoad.rightWidth +
|
|
|
|
- curveRoad.midDivide.midDivideWidth
|
|
|
|
- );
|
|
|
|
|
|
+ edgePoints = mathUtil.RectangleVertex(newStartPoint, newEndPoint, curveRoad.leftWidth + curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth);
|
|
}
|
|
}
|
|
|
|
|
|
- let leftEdge = curveEdgeService.create(
|
|
|
|
- edgePoints.leftEdgeStart,
|
|
|
|
- edgePoints.leftEdgeEnd,
|
|
|
|
- null,
|
|
|
|
- newCurveRoad.vectorId
|
|
|
|
- );
|
|
|
|
|
|
+ let leftEdge = curveEdgeService.create(edgePoints.leftEdgeStart, edgePoints.leftEdgeEnd, null, newCurveRoad.vectorId);
|
|
|
|
|
|
- let rightEdge = curveEdgeService.create(
|
|
|
|
- edgePoints.rightEdgeStart,
|
|
|
|
- edgePoints.rightEdgeEnd,
|
|
|
|
- null,
|
|
|
|
- newCurveRoad.vectorId
|
|
|
|
- );
|
|
|
|
|
|
+ let rightEdge = curveEdgeService.create(edgePoints.rightEdgeStart, edgePoints.rightEdgeEnd, null, newCurveRoad.vectorId);
|
|
|
|
|
|
newCurveRoad.setLeftEdge(leftEdge.vectorId);
|
|
newCurveRoad.setLeftEdge(leftEdge.vectorId);
|
|
newCurveRoad.setRightEdge(rightEdge.vectorId);
|
|
newCurveRoad.setRightEdge(rightEdge.vectorId);
|
|
@@ -170,18 +128,12 @@ export default class CurveRoadService extends RoadService {
|
|
rightEdge.points.push(edgePoints.rightEdgeEnd);
|
|
rightEdge.points.push(edgePoints.rightEdgeEnd);
|
|
|
|
|
|
for (let i = 1; i < curveRoad.points.length - 1; ++i) {
|
|
for (let i = 1; i < curveRoad.points.length - 1; ++i) {
|
|
- this.addCPoint(
|
|
|
|
- newCurveRoad,
|
|
|
|
- uiService.getNewPositionForPop(curveRoad.points[i]),
|
|
|
|
- curveRoad.points[i].getIndex()
|
|
|
|
- );
|
|
|
|
|
|
+ this.addCPoint(newCurveRoad, uiService.getNewPositionForPop(curveRoad.points[i]), curveRoad.points[i].getIndex());
|
|
}
|
|
}
|
|
|
|
|
|
const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
|
|
const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
|
|
for (let i = 0; i < leftEdge.points.length; ++i) {
|
|
for (let i = 0; i < leftEdge.points.length; ++i) {
|
|
- leftEdge.points[i] = uiService.getNewPositionForPop(
|
|
|
|
- leftCurveEdge.points[i]
|
|
|
|
- );
|
|
|
|
|
|
+ leftEdge.points[i] = uiService.getNewPositionForPop(leftCurveEdge.points[i]);
|
|
}
|
|
}
|
|
leftEdge.start = uiService.getNewPositionForPop(leftCurveEdge.start);
|
|
leftEdge.start = uiService.getNewPositionForPop(leftCurveEdge.start);
|
|
leftEdge.end = uiService.getNewPositionForPop(leftCurveEdge.end);
|
|
leftEdge.end = uiService.getNewPositionForPop(leftCurveEdge.end);
|
|
@@ -190,9 +142,7 @@ export default class CurveRoadService extends RoadService {
|
|
|
|
|
|
const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
|
|
const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
|
|
for (let i = 0; i < rightEdge.points.length; ++i) {
|
|
for (let i = 0; i < rightEdge.points.length; ++i) {
|
|
- rightEdge.points[i] = uiService.getNewPositionForPop(
|
|
|
|
- rightCurveEdge.points[i]
|
|
|
|
- );
|
|
|
|
|
|
+ rightEdge.points[i] = uiService.getNewPositionForPop(rightCurveEdge.points[i]);
|
|
}
|
|
}
|
|
rightEdge.start = uiService.getNewPositionForPop(rightCurveEdge.start);
|
|
rightEdge.start = uiService.getNewPositionForPop(rightCurveEdge.start);
|
|
rightEdge.end = uiService.getNewPositionForPop(rightCurveEdge.end);
|
|
rightEdge.end = uiService.getNewPositionForPop(rightCurveEdge.end);
|
|
@@ -258,26 +208,11 @@ export default class CurveRoadService extends RoadService {
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
curveRoad.startId = point.vectorId;
|
|
curveRoad.startId = point.vectorId;
|
|
} else if (startIndex == curveRoad.points.length - 1) {
|
|
} else if (startIndex == curveRoad.points.length - 1) {
|
|
- let line = mathUtil.createLine1(
|
|
|
|
- curveRoad.points[startIndex],
|
|
|
|
- curveRoad.points[startIndex - 1]
|
|
|
|
- );
|
|
|
|
- let leftLine = mathUtil.createLine3(
|
|
|
|
- line,
|
|
|
|
- leftCurveEdge.points[startIndex - 1]
|
|
|
|
- );
|
|
|
|
- let rightLine = mathUtil.createLine3(
|
|
|
|
- line,
|
|
|
|
- rightCurveEdge.points[startIndex - 1]
|
|
|
|
- );
|
|
|
|
- let leftJoin = mathUtil.getJoinLinePoint(
|
|
|
|
- curveRoad.points[startIndex],
|
|
|
|
- leftLine
|
|
|
|
- );
|
|
|
|
- let rightJoin = mathUtil.getJoinLinePoint(
|
|
|
|
- curveRoad.points[startIndex],
|
|
|
|
- rightLine
|
|
|
|
- );
|
|
|
|
|
|
+ let line = mathUtil.createLine1(curveRoad.points[startIndex], curveRoad.points[startIndex - 1]);
|
|
|
|
+ let leftLine = mathUtil.createLine3(line, leftCurveEdge.points[startIndex - 1]);
|
|
|
|
+ let rightLine = mathUtil.createLine3(line, rightCurveEdge.points[startIndex - 1]);
|
|
|
|
+ let leftJoin = mathUtil.getJoinLinePoint(curveRoad.points[startIndex], leftLine);
|
|
|
|
+ let rightJoin = mathUtil.getJoinLinePoint(curveRoad.points[startIndex], rightLine);
|
|
|
|
|
|
leftCurveEdge.end = JSON.parse(JSON.stringify(leftJoin));
|
|
leftCurveEdge.end = JSON.parse(JSON.stringify(leftJoin));
|
|
//mathUtil.clonePoint(leftCurveEdge.end, leftJoin);
|
|
//mathUtil.clonePoint(leftCurveEdge.end, leftJoin);
|
|
@@ -290,69 +225,36 @@ export default class CurveRoadService extends RoadService {
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
curveRoad.endId = point.vectorId;
|
|
curveRoad.endId = point.vectorId;
|
|
} else {
|
|
} else {
|
|
- if (
|
|
|
|
- mathUtil.Angle(
|
|
|
|
- curveRoad.points[startIndex],
|
|
|
|
- curveRoad.points[startIndex - 1],
|
|
|
|
- curveRoad.points[startIndex + 1]
|
|
|
|
- ) > Constant.maxAngle
|
|
|
|
- ) {
|
|
|
|
- let line = mathUtil.createLine1(
|
|
|
|
- curveRoad.points[startIndex - 1],
|
|
|
|
- curveRoad.points[startIndex + 1]
|
|
|
|
- );
|
|
|
|
|
|
+ if (mathUtil.Angle(curveRoad.points[startIndex], curveRoad.points[startIndex - 1], curveRoad.points[startIndex + 1]) > Constant.maxAngle) {
|
|
|
|
+ let line = mathUtil.createLine1(curveRoad.points[startIndex - 1], curveRoad.points[startIndex + 1]);
|
|
const join = mathUtil.getJoinLinePoint(position, line);
|
|
const join = mathUtil.getJoinLinePoint(position, line);
|
|
let dx = position.x - join.x;
|
|
let dx = position.x - join.x;
|
|
let dy = position.y - join.y;
|
|
let dy = position.y - join.y;
|
|
|
|
|
|
- let leftLine = mathUtil.createLine1(
|
|
|
|
- leftCurveEdge.points[startIndex - 1],
|
|
|
|
- leftCurveEdge.points[startIndex]
|
|
|
|
- );
|
|
|
|
|
|
+ let leftLine = mathUtil.createLine1(leftCurveEdge.points[startIndex - 1], leftCurveEdge.points[startIndex]);
|
|
leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
|
|
leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
|
|
leftJoin.x += dx;
|
|
leftJoin.x += dx;
|
|
leftJoin.y += dy;
|
|
leftJoin.y += dy;
|
|
leftCurveEdge.points.splice(startIndex, 0, leftJoin);
|
|
leftCurveEdge.points.splice(startIndex, 0, leftJoin);
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
|
|
|
|
- let rightLine = mathUtil.createLine1(
|
|
|
|
- rightCurveEdge.points[startIndex - 1],
|
|
|
|
- rightCurveEdge.points[startIndex]
|
|
|
|
- );
|
|
|
|
|
|
+ let rightLine = mathUtil.createLine1(rightCurveEdge.points[startIndex - 1], rightCurveEdge.points[startIndex]);
|
|
rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
|
|
rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
|
|
rightJoin.x += dx;
|
|
rightJoin.x += dx;
|
|
rightJoin.y += dy;
|
|
rightJoin.y += dy;
|
|
rightCurveEdge.points.splice(startIndex, 0, rightJoin);
|
|
rightCurveEdge.points.splice(startIndex, 0, rightJoin);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
} else {
|
|
} else {
|
|
- let line1 = mathUtil.createLine1(
|
|
|
|
- curveRoad.points[startIndex - 1],
|
|
|
|
- curveRoad.points[startIndex]
|
|
|
|
- );
|
|
|
|
- let line2 = mathUtil.createLine1(
|
|
|
|
- curveRoad.points[startIndex],
|
|
|
|
- curveRoad.points[startIndex + 1]
|
|
|
|
- );
|
|
|
|
- let leftLine1 = mathUtil.createLine3(
|
|
|
|
- line1,
|
|
|
|
- leftCurveEdge.points[startIndex - 1]
|
|
|
|
- );
|
|
|
|
- let leftLine2 = mathUtil.createLine3(
|
|
|
|
- line2,
|
|
|
|
- leftCurveEdge.points[startIndex]
|
|
|
|
- );
|
|
|
|
|
|
+ let line1 = mathUtil.createLine1(curveRoad.points[startIndex - 1], curveRoad.points[startIndex]);
|
|
|
|
+ let line2 = mathUtil.createLine1(curveRoad.points[startIndex], curveRoad.points[startIndex + 1]);
|
|
|
|
+ let leftLine1 = mathUtil.createLine3(line1, leftCurveEdge.points[startIndex - 1]);
|
|
|
|
+ let leftLine2 = mathUtil.createLine3(line2, leftCurveEdge.points[startIndex]);
|
|
leftJoin = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
|
|
leftJoin = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
|
|
leftCurveEdge.points.splice(startIndex, 0, leftJoin);
|
|
leftCurveEdge.points.splice(startIndex, 0, leftJoin);
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
|
|
|
|
- let rightLine1 = mathUtil.createLine3(
|
|
|
|
- line1,
|
|
|
|
- rightCurveEdge.points[startIndex - 1]
|
|
|
|
- );
|
|
|
|
- let rightLine2 = mathUtil.createLine3(
|
|
|
|
- line2,
|
|
|
|
- rightCurveEdge.points[startIndex]
|
|
|
|
- );
|
|
|
|
|
|
+ let rightLine1 = mathUtil.createLine3(line1, rightCurveEdge.points[startIndex - 1]);
|
|
|
|
+ let rightLine2 = mathUtil.createLine3(line2, rightCurveEdge.points[startIndex]);
|
|
rightJoin = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
|
|
rightJoin = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
|
|
rightCurveEdge.points.splice(startIndex, 0, rightJoin);
|
|
rightCurveEdge.points.splice(startIndex, 0, rightJoin);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
@@ -500,12 +402,8 @@ export default class CurveRoadService extends RoadService {
|
|
singleLanes[i] = [];
|
|
singleLanes[i] = [];
|
|
}
|
|
}
|
|
|
|
|
|
- const dx =
|
|
|
|
- (leftEdgePoints[j].x - rightEdgePoints[j].x) /
|
|
|
|
- singleRoadDrivewayCount;
|
|
|
|
- const dy =
|
|
|
|
- (leftEdgePoints[j].y - rightEdgePoints[j].y) /
|
|
|
|
- singleRoadDrivewayCount;
|
|
|
|
|
|
+ const dx = (leftEdgePoints[j].x - rightEdgePoints[j].x) / singleRoadDrivewayCount;
|
|
|
|
+ const dy = (leftEdgePoints[j].y - rightEdgePoints[j].y) / singleRoadDrivewayCount;
|
|
|
|
|
|
singleLanes[i][j] = {};
|
|
singleLanes[i][j] = {};
|
|
singleLanes[i][j].x = points[j].x + dx;
|
|
singleLanes[i][j].x = points[j].x + dx;
|
|
@@ -548,13 +446,9 @@ export default class CurveRoadService extends RoadService {
|
|
if (!leftLanes[i]) {
|
|
if (!leftLanes[i]) {
|
|
leftLanes[i] = [];
|
|
leftLanes[i] = [];
|
|
}
|
|
}
|
|
- const leftRatio =
|
|
|
|
- curveRoad.leftWidth /
|
|
|
|
- (curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
|
|
- const leftdx =
|
|
|
|
- ((leftEdgePoints[j].x - points[j].x) * leftRatio) / leftCount;
|
|
|
|
- const leftdy =
|
|
|
|
- ((leftEdgePoints[j].y - points[j].y) * leftRatio) / leftCount;
|
|
|
|
|
|
+ const leftRatio = curveRoad.leftWidth / (curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
|
|
+ const leftdx = ((leftEdgePoints[j].x - points[j].x) * leftRatio) / leftCount;
|
|
|
|
+ const leftdy = ((leftEdgePoints[j].y - points[j].y) * leftRatio) / leftCount;
|
|
const middx = (leftEdgePoints[j].x - points[j].x) * (1 - leftRatio);
|
|
const middx = (leftEdgePoints[j].x - points[j].x) * (1 - leftRatio);
|
|
const middy = (leftEdgePoints[j].y - points[j].y) * (1 - leftRatio);
|
|
const middy = (leftEdgePoints[j].y - points[j].y) * (1 - leftRatio);
|
|
leftLanes[i][j] = {};
|
|
leftLanes[i][j] = {};
|
|
@@ -571,9 +465,7 @@ export default class CurveRoadService extends RoadService {
|
|
|
|
|
|
if (leftMidDivide.length == 0) {
|
|
if (leftMidDivide.length == 0) {
|
|
for (let j = 0; j < points.length; ++j) {
|
|
for (let j = 0; j < points.length; ++j) {
|
|
- const leftRatio =
|
|
|
|
- curveRoad.leftWidth /
|
|
|
|
- (curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
|
|
|
|
+ const leftRatio = curveRoad.leftWidth / (curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
const middx = (leftEdgePoints[j].x - points[j].x) * (1 - leftRatio);
|
|
const middx = (leftEdgePoints[j].x - points[j].x) * (1 - leftRatio);
|
|
const middy = (leftEdgePoints[j].y - points[j].y) * (1 - leftRatio);
|
|
const middy = (leftEdgePoints[j].y - points[j].y) * (1 - leftRatio);
|
|
leftMidDivide[j] = {};
|
|
leftMidDivide[j] = {};
|
|
@@ -582,8 +474,7 @@ export default class CurveRoadService extends RoadService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
curveRoad.midDivide.leftMidDivide = leftMidDivide;
|
|
curveRoad.midDivide.leftMidDivide = leftMidDivide;
|
|
- curveRoad.midDivide.leftMidDivideCurves =
|
|
|
|
- mathUtil.getCurvesByPoints(leftMidDivide);
|
|
|
|
|
|
+ curveRoad.midDivide.leftMidDivideCurves = mathUtil.getCurvesByPoints(leftMidDivide);
|
|
|
|
|
|
curveRoad.leftLanes = leftLanes;
|
|
curveRoad.leftLanes = leftLanes;
|
|
curveRoad.leftLanesCurves = leftLanesCurves;
|
|
curveRoad.leftLanesCurves = leftLanesCurves;
|
|
@@ -595,13 +486,9 @@ export default class CurveRoadService extends RoadService {
|
|
if (!rightLanes[i]) {
|
|
if (!rightLanes[i]) {
|
|
rightLanes[i] = [];
|
|
rightLanes[i] = [];
|
|
}
|
|
}
|
|
- const rightRatio =
|
|
|
|
- curveRoad.rightWidth /
|
|
|
|
- (curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
|
|
- const rightdx =
|
|
|
|
- ((rightEdgePoints[j].x - points[j].x) * rightRatio) / rightCount;
|
|
|
|
- const rightdy =
|
|
|
|
- ((rightEdgePoints[j].y - points[j].y) * rightRatio) / rightCount;
|
|
|
|
|
|
+ const rightRatio = curveRoad.rightWidth / (curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
|
|
+ const rightdx = ((rightEdgePoints[j].x - points[j].x) * rightRatio) / rightCount;
|
|
|
|
+ const rightdy = ((rightEdgePoints[j].y - points[j].y) * rightRatio) / rightCount;
|
|
const middx = (rightEdgePoints[j].x - points[j].x) * (1 - rightRatio);
|
|
const middx = (rightEdgePoints[j].x - points[j].x) * (1 - rightRatio);
|
|
const middy = (rightEdgePoints[j].y - points[j].y) * (1 - rightRatio);
|
|
const middy = (rightEdgePoints[j].y - points[j].y) * (1 - rightRatio);
|
|
rightLanes[i][j] = {};
|
|
rightLanes[i][j] = {};
|
|
@@ -617,9 +504,7 @@ export default class CurveRoadService extends RoadService {
|
|
}
|
|
}
|
|
if (rightMidDivide.length == 0) {
|
|
if (rightMidDivide.length == 0) {
|
|
for (let j = 0; j < points.length; ++j) {
|
|
for (let j = 0; j < points.length; ++j) {
|
|
- const rightRatio =
|
|
|
|
- curveRoad.rightWidth /
|
|
|
|
- (curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
|
|
|
|
+ const rightRatio = curveRoad.rightWidth / (curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
const middx = (rightEdgePoints[j].x - points[j].x) * (1 - rightRatio);
|
|
const middx = (rightEdgePoints[j].x - points[j].x) * (1 - rightRatio);
|
|
const middy = (rightEdgePoints[j].y - points[j].y) * (1 - rightRatio);
|
|
const middy = (rightEdgePoints[j].y - points[j].y) * (1 - rightRatio);
|
|
rightMidDivide[j] = {};
|
|
rightMidDivide[j] = {};
|
|
@@ -628,8 +513,7 @@ export default class CurveRoadService extends RoadService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
curveRoad.midDivide.rightMidDivide = rightMidDivide;
|
|
curveRoad.midDivide.rightMidDivide = rightMidDivide;
|
|
- curveRoad.midDivide.rightMidDivideCurves =
|
|
|
|
- mathUtil.getCurvesByPoints(rightMidDivide);
|
|
|
|
|
|
+ curveRoad.midDivide.rightMidDivideCurves = mathUtil.getCurvesByPoints(rightMidDivide);
|
|
curveRoad.rightLanes = rightLanes;
|
|
curveRoad.rightLanes = rightLanes;
|
|
curveRoad.rightLanesCurves = rightLanesCurves;
|
|
curveRoad.rightLanesCurves = rightLanesCurves;
|
|
}
|
|
}
|
|
@@ -663,17 +547,13 @@ export default class CurveRoadService extends RoadService {
|
|
oldCount = curveRoad.leftDrivewayCount;
|
|
oldCount = curveRoad.leftDrivewayCount;
|
|
curveRoad.leftDrivewayCount = newCount;
|
|
curveRoad.leftDrivewayCount = newCount;
|
|
lanes = curveRoad.leftLanes;
|
|
lanes = curveRoad.leftLanes;
|
|
- ratio =
|
|
|
|
- curveRoad.leftWidth /
|
|
|
|
- (curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
|
|
|
|
+ ratio = curveRoad.leftWidth / (curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
} else if (dir == "right") {
|
|
} else if (dir == "right") {
|
|
curveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
|
|
curveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
|
|
oldCount = curveRoad.rightDrivewayCount;
|
|
oldCount = curveRoad.rightDrivewayCount;
|
|
curveRoad.rightDrivewayCount = newCount;
|
|
curveRoad.rightDrivewayCount = newCount;
|
|
lanes = curveRoad.rightLanes;
|
|
lanes = curveRoad.rightLanes;
|
|
- ratio =
|
|
|
|
- curveRoad.rightWidth /
|
|
|
|
- (curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
|
|
|
|
+ ratio = curveRoad.rightWidth / (curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -689,78 +569,48 @@ export default class CurveRoadService extends RoadService {
|
|
|
|
|
|
if (curveRoad.way == Constant.twoWay) {
|
|
if (curveRoad.way == Constant.twoWay) {
|
|
for (let i = 0; i < curveRoad.points.length; ++i) {
|
|
for (let i = 0; i < curveRoad.points.length; ++i) {
|
|
- const middx =
|
|
|
|
- (curveEdge.points[i].x - curveRoad.points[i].x) * (1 - ratio);
|
|
|
|
- const middy =
|
|
|
|
- (curveEdge.points[i].y - curveRoad.points[i].y) * (1 - ratio);
|
|
|
|
- const dx =
|
|
|
|
- ((curveEdge.points[i].x - curveRoad.points[i].x) * ratio) / oldCount;
|
|
|
|
|
|
+ const middx = (curveEdge.points[i].x - curveRoad.points[i].x) * (1 - ratio);
|
|
|
|
+ const middy = (curveEdge.points[i].y - curveRoad.points[i].y) * (1 - ratio);
|
|
|
|
+ const dx = ((curveEdge.points[i].x - curveRoad.points[i].x) * ratio) / oldCount;
|
|
curveEdge.points[i].x = curveRoad.points[i].x + middx + dx * newCount;
|
|
curveEdge.points[i].x = curveRoad.points[i].x + middx + dx * newCount;
|
|
- const dy =
|
|
|
|
- ((curveEdge.points[i].y - curveRoad.points[i].y) * ratio) / oldCount;
|
|
|
|
|
|
+ const dy = ((curveEdge.points[i].y - curveRoad.points[i].y) * ratio) / oldCount;
|
|
curveEdge.points[i].y = curveRoad.points[i].y + middy + dy * newCount;
|
|
curveEdge.points[i].y = curveRoad.points[i].y + middy + dy * newCount;
|
|
}
|
|
}
|
|
|
|
|
|
mathUtil.clonePoint(curveEdge.start, curveEdge.points[0]);
|
|
mathUtil.clonePoint(curveEdge.start, curveEdge.points[0]);
|
|
- mathUtil.clonePoint(
|
|
|
|
- curveEdge.end,
|
|
|
|
- curveEdge.points[curveEdge.points.length - 1]
|
|
|
|
- );
|
|
|
|
|
|
+ mathUtil.clonePoint(curveEdge.end, curveEdge.points[curveEdge.points.length - 1]);
|
|
curveEdgeService.setCurves(curveEdge);
|
|
curveEdgeService.setCurves(curveEdge);
|
|
- const line = mathUtil.createLine1(
|
|
|
|
- curveRoad.points[0],
|
|
|
|
- curveRoad.points[1]
|
|
|
|
- );
|
|
|
|
|
|
+ const line = mathUtil.createLine1(curveRoad.points[0], curveRoad.points[1]);
|
|
if (dir == "left") {
|
|
if (dir == "left") {
|
|
- const leftWidth =
|
|
|
|
- mathUtil.getDisForPoinLine(leftCurveEdge.start, line) -
|
|
|
|
- curveRoad.midDivide.midDivideWidth / 2;
|
|
|
|
|
|
+ const leftWidth = mathUtil.getDisForPoinLine(leftCurveEdge.start, line) - curveRoad.midDivide.midDivideWidth / 2;
|
|
curveRoad.setWidth(leftWidth, "left");
|
|
curveRoad.setWidth(leftWidth, "left");
|
|
} else if (dir == "right") {
|
|
} else if (dir == "right") {
|
|
- const rightWidth =
|
|
|
|
- mathUtil.getDisForPoinLine(rightCurveEdge.start, line) -
|
|
|
|
- curveRoad.midDivide.midDivideWidth / 2;
|
|
|
|
|
|
+ const rightWidth = mathUtil.getDisForPoinLine(rightCurveEdge.start, line) - curveRoad.midDivide.midDivideWidth / 2;
|
|
curveRoad.setWidth(rightWidth, "right");
|
|
curveRoad.setWidth(rightWidth, "right");
|
|
}
|
|
}
|
|
} else if (curveRoad.way == Constant.oneWay) {
|
|
} else if (curveRoad.way == Constant.oneWay) {
|
|
oldCount = curveRoad.singleRoadDrivewayCount;
|
|
oldCount = curveRoad.singleRoadDrivewayCount;
|
|
for (let i = 0; i < curveRoad.points.length; ++i) {
|
|
for (let i = 0; i < curveRoad.points.length; ++i) {
|
|
- let dx =
|
|
|
|
- (leftCurveEdge.points[i].x - rightCurveEdge.points[i].x) / oldCount;
|
|
|
|
- let dy =
|
|
|
|
- (leftCurveEdge.points[i].y - rightCurveEdge.points[i].y) / oldCount;
|
|
|
|
|
|
+ let dx = (leftCurveEdge.points[i].x - rightCurveEdge.points[i].x) / oldCount;
|
|
|
|
+ let dy = (leftCurveEdge.points[i].y - rightCurveEdge.points[i].y) / oldCount;
|
|
|
|
|
|
leftCurveEdge.points[i].x = curveRoad.points[i].x + (dx * newCount) / 2;
|
|
leftCurveEdge.points[i].x = curveRoad.points[i].x + (dx * newCount) / 2;
|
|
leftCurveEdge.points[i].y = curveRoad.points[i].y + (dy * newCount) / 2;
|
|
leftCurveEdge.points[i].y = curveRoad.points[i].y + (dy * newCount) / 2;
|
|
mathUtil.clonePoint(leftCurveEdge.start, leftCurveEdge.points[0]);
|
|
mathUtil.clonePoint(leftCurveEdge.start, leftCurveEdge.points[0]);
|
|
- mathUtil.clonePoint(
|
|
|
|
- leftCurveEdge.end,
|
|
|
|
- leftCurveEdge.points[leftCurveEdge.points.length - 1]
|
|
|
|
- );
|
|
|
|
|
|
+ mathUtil.clonePoint(leftCurveEdge.end, leftCurveEdge.points[leftCurveEdge.points.length - 1]);
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
|
|
|
|
dx = -1 * dx;
|
|
dx = -1 * dx;
|
|
dy = -1 * dy;
|
|
dy = -1 * dy;
|
|
- rightCurveEdge.points[i].x =
|
|
|
|
- curveRoad.points[i].x + (dx * newCount) / 2;
|
|
|
|
- rightCurveEdge.points[i].y =
|
|
|
|
- curveRoad.points[i].y + (dy * newCount) / 2;
|
|
|
|
|
|
+ rightCurveEdge.points[i].x = curveRoad.points[i].x + (dx * newCount) / 2;
|
|
|
|
+ rightCurveEdge.points[i].y = curveRoad.points[i].y + (dy * newCount) / 2;
|
|
mathUtil.clonePoint(rightCurveEdge.start, rightCurveEdge.points[0]);
|
|
mathUtil.clonePoint(rightCurveEdge.start, rightCurveEdge.points[0]);
|
|
- mathUtil.clonePoint(
|
|
|
|
- rightCurveEdge.end,
|
|
|
|
- rightCurveEdge.points[rightCurveEdge.points.length - 1]
|
|
|
|
- );
|
|
|
|
|
|
+ mathUtil.clonePoint(rightCurveEdge.end, rightCurveEdge.points[rightCurveEdge.points.length - 1]);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
}
|
|
}
|
|
|
|
|
|
- const line = mathUtil.createLine1(
|
|
|
|
- curveRoad.leftCurveEdge.points[0],
|
|
|
|
- curveRoad.leftCurveEdge.points[1]
|
|
|
|
- );
|
|
|
|
- const singleRoadWidth = mathUtil.getDisForPoinLine(
|
|
|
|
- rightCurveEdge.start,
|
|
|
|
- line
|
|
|
|
- );
|
|
|
|
|
|
+ const line = mathUtil.createLine1(curveRoad.leftCurveEdge.points[0], curveRoad.leftCurveEdge.points[1]);
|
|
|
|
+ const singleRoadWidth = mathUtil.getDisForPoinLine(rightCurveEdge.start, line);
|
|
curveRoad.setWidth(singleRoadWidth);
|
|
curveRoad.setWidth(singleRoadWidth);
|
|
}
|
|
}
|
|
this.setLanes(curveRoad.vectorId, dir);
|
|
this.setLanes(curveRoad.vectorId, dir);
|
|
@@ -803,17 +653,9 @@ export default class CurveRoadService extends RoadService {
|
|
}
|
|
}
|
|
let edgePoints = null;
|
|
let edgePoints = null;
|
|
if (curveRoad.way == Constant.oneWay) {
|
|
if (curveRoad.way == Constant.oneWay) {
|
|
- edgePoints = mathUtil.getOffset(
|
|
|
|
- curveRoad.points,
|
|
|
|
- curveRoad.singleRoadWidth / 2,
|
|
|
|
- curveRoad.singleRoadWidth / 2
|
|
|
|
- );
|
|
|
|
|
|
+ edgePoints = mathUtil.getOffset(curveRoad.points, curveRoad.singleRoadWidth / 2, curveRoad.singleRoadWidth / 2);
|
|
} else if (curveRoad.way == Constant.twoWay) {
|
|
} else if (curveRoad.way == Constant.twoWay) {
|
|
- edgePoints = mathUtil.getOffset(
|
|
|
|
- curveRoad.points,
|
|
|
|
- curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2,
|
|
|
|
- curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2
|
|
|
|
- );
|
|
|
|
|
|
+ edgePoints = mathUtil.getOffset(curveRoad.points, curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2, curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
|
|
}
|
|
}
|
|
|
|
|
|
if (!edgePoints) {
|
|
if (!edgePoints) {
|
|
@@ -825,8 +667,7 @@ export default class CurveRoadService extends RoadService {
|
|
|
|
|
|
rightCurveEdge.points = edgePoints.rightEdgePoints;
|
|
rightCurveEdge.points = edgePoints.rightEdgePoints;
|
|
rightCurveEdge.start = rightCurveEdge.points[0];
|
|
rightCurveEdge.start = rightCurveEdge.points[0];
|
|
- rightCurveEdge.end =
|
|
|
|
- rightCurveEdge.points[rightCurveEdge.points.length - 1];
|
|
|
|
|
|
+ rightCurveEdge.end = rightCurveEdge.points[rightCurveEdge.points.length - 1];
|
|
|
|
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
@@ -956,68 +797,26 @@ export default class CurveRoadService extends RoadService {
|
|
if (dir == "left" || !dir) {
|
|
if (dir == "left" || !dir) {
|
|
for (let i = 0; i < leftCurveEdge.points.length; ++i) {
|
|
for (let i = 0; i < leftCurveEdge.points.length; ++i) {
|
|
if (i == 0) {
|
|
if (i == 0) {
|
|
- let points1 = mathUtil.RectangleVertex(
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- curveRoad.points[i + 1],
|
|
|
|
- (newWidth + midDivideWidth / 2) * coordinate.ratio
|
|
|
|
- );
|
|
|
|
- line1 = mathUtil.createLine1(
|
|
|
|
- points1.leftEdgeStart,
|
|
|
|
- points1.leftEdgeEnd
|
|
|
|
- );
|
|
|
|
|
|
+ let points1 = mathUtil.RectangleVertex(curveRoad.points[i], curveRoad.points[i + 1], (newWidth + midDivideWidth / 2) * coordinate.ratio);
|
|
|
|
+ line1 = mathUtil.createLine1(points1.leftEdgeStart, points1.leftEdgeEnd);
|
|
let leftJoin = mathUtil.getJoinLinePoint(curveRoad.points[0], line1);
|
|
let leftJoin = mathUtil.getJoinLinePoint(curveRoad.points[0], line1);
|
|
leftCurveEdge.start = JSON.parse(JSON.stringify(leftJoin));
|
|
leftCurveEdge.start = JSON.parse(JSON.stringify(leftJoin));
|
|
leftCurveEdge.points[0] = JSON.parse(JSON.stringify(leftJoin));
|
|
leftCurveEdge.points[0] = JSON.parse(JSON.stringify(leftJoin));
|
|
} else if (i == leftCurveEdge.points.length - 1) {
|
|
} else if (i == leftCurveEdge.points.length - 1) {
|
|
- let points1 = mathUtil.RectangleVertex(
|
|
|
|
- curveRoad.points[i - 1],
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- (newWidth + midDivideWidth / 2) * coordinate.ratio
|
|
|
|
- );
|
|
|
|
- line1 = mathUtil.createLine1(
|
|
|
|
- points1.leftEdgeStart,
|
|
|
|
- points1.leftEdgeEnd
|
|
|
|
- );
|
|
|
|
- let leftJoin = mathUtil.getJoinLinePoint(
|
|
|
|
- curveRoad.points[curveRoad.points.length - 1],
|
|
|
|
- line1
|
|
|
|
- );
|
|
|
|
|
|
+ let points1 = mathUtil.RectangleVertex(curveRoad.points[i - 1], curveRoad.points[i], (newWidth + midDivideWidth / 2) * coordinate.ratio);
|
|
|
|
+ line1 = mathUtil.createLine1(points1.leftEdgeStart, points1.leftEdgeEnd);
|
|
|
|
+ let leftJoin = mathUtil.getJoinLinePoint(curveRoad.points[curveRoad.points.length - 1], line1);
|
|
leftCurveEdge.end = JSON.parse(JSON.stringify(leftJoin));
|
|
leftCurveEdge.end = JSON.parse(JSON.stringify(leftJoin));
|
|
- leftCurveEdge.points[leftCurveEdge.points.length - 1] = JSON.parse(
|
|
|
|
- JSON.stringify(leftJoin)
|
|
|
|
- );
|
|
|
|
|
|
+ leftCurveEdge.points[leftCurveEdge.points.length - 1] = JSON.parse(JSON.stringify(leftJoin));
|
|
} else {
|
|
} else {
|
|
- if (
|
|
|
|
- mathUtil.Angle(
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- curveRoad.points[i - 1],
|
|
|
|
- curveRoad.points[i + 1]
|
|
|
|
- ) > Constant.maxAngle
|
|
|
|
- ) {
|
|
|
|
- let leftJoin = mathUtil.getJoinLinePoint(
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- line1
|
|
|
|
- );
|
|
|
|
|
|
+ if (mathUtil.Angle(curveRoad.points[i], curveRoad.points[i - 1], curveRoad.points[i + 1]) > Constant.maxAngle) {
|
|
|
|
+ let leftJoin = mathUtil.getJoinLinePoint(curveRoad.points[i], line1);
|
|
leftCurveEdge.points[i] = JSON.parse(JSON.stringify(leftJoin));
|
|
leftCurveEdge.points[i] = JSON.parse(JSON.stringify(leftJoin));
|
|
} else {
|
|
} else {
|
|
- let points1 = mathUtil.RectangleVertex(
|
|
|
|
- curveRoad.points[i - 1],
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- (newWidth + midDivideWidth / 2) * coordinate.ratio
|
|
|
|
- );
|
|
|
|
- line1 = mathUtil.createLine1(
|
|
|
|
- points1.leftEdgeStart,
|
|
|
|
- points1.leftEdgeEnd
|
|
|
|
- );
|
|
|
|
- let points2 = mathUtil.RectangleVertex(
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- curveRoad.points[i + 1],
|
|
|
|
- (newWidth + midDivideWidth / 2) * coordinate.ratio
|
|
|
|
- );
|
|
|
|
- line2 = mathUtil.createLine1(
|
|
|
|
- points2.leftEdgeStart,
|
|
|
|
- points2.leftEdgeEnd
|
|
|
|
- );
|
|
|
|
|
|
+ let points1 = mathUtil.RectangleVertex(curveRoad.points[i - 1], curveRoad.points[i], (newWidth + midDivideWidth / 2) * coordinate.ratio);
|
|
|
|
+ line1 = mathUtil.createLine1(points1.leftEdgeStart, points1.leftEdgeEnd);
|
|
|
|
+ let points2 = mathUtil.RectangleVertex(curveRoad.points[i], curveRoad.points[i + 1], (newWidth + midDivideWidth / 2) * coordinate.ratio);
|
|
|
|
+ line2 = mathUtil.createLine1(points2.leftEdgeStart, points2.leftEdgeEnd);
|
|
let leftJoin = mathUtil.getIntersectionPoint(line1, line2);
|
|
let leftJoin = mathUtil.getIntersectionPoint(line1, line2);
|
|
leftCurveEdge.points[i] = JSON.parse(JSON.stringify(leftJoin));
|
|
leftCurveEdge.points[i] = JSON.parse(JSON.stringify(leftJoin));
|
|
}
|
|
}
|
|
@@ -1028,68 +827,26 @@ export default class CurveRoadService extends RoadService {
|
|
if (dir == "right" || !dir) {
|
|
if (dir == "right" || !dir) {
|
|
for (let i = 0; i < rightCurveEdge.points.length; ++i) {
|
|
for (let i = 0; i < rightCurveEdge.points.length; ++i) {
|
|
if (i == 0) {
|
|
if (i == 0) {
|
|
- let points1 = mathUtil.RectangleVertex(
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- curveRoad.points[i + 1],
|
|
|
|
- (newWidth + midDivideWidth / 2) * coordinate.ratio
|
|
|
|
- );
|
|
|
|
- line1 = mathUtil.createLine1(
|
|
|
|
- points1.rightEdgeStart,
|
|
|
|
- points1.rightEdgeEnd
|
|
|
|
- );
|
|
|
|
|
|
+ let points1 = mathUtil.RectangleVertex(curveRoad.points[i], curveRoad.points[i + 1], (newWidth + midDivideWidth / 2) * coordinate.ratio);
|
|
|
|
+ line1 = mathUtil.createLine1(points1.rightEdgeStart, points1.rightEdgeEnd);
|
|
let rightJoin = mathUtil.getJoinLinePoint(curveRoad.points[0], line1);
|
|
let rightJoin = mathUtil.getJoinLinePoint(curveRoad.points[0], line1);
|
|
rightCurveEdge.start = JSON.parse(JSON.stringify(rightJoin));
|
|
rightCurveEdge.start = JSON.parse(JSON.stringify(rightJoin));
|
|
rightCurveEdge.points[0] = JSON.parse(JSON.stringify(rightJoin));
|
|
rightCurveEdge.points[0] = JSON.parse(JSON.stringify(rightJoin));
|
|
} else if (i == rightCurveEdge.points.length - 1) {
|
|
} else if (i == rightCurveEdge.points.length - 1) {
|
|
- let points1 = mathUtil.RectangleVertex(
|
|
|
|
- curveRoad.points[i - 1],
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- (newWidth + midDivideWidth / 2) * coordinate.ratio
|
|
|
|
- );
|
|
|
|
- line1 = mathUtil.createLine1(
|
|
|
|
- points1.rightEdgeStart,
|
|
|
|
- points1.rightEdgeEnd
|
|
|
|
- );
|
|
|
|
- let rightJoin = mathUtil.getJoinLinePoint(
|
|
|
|
- curveRoad.points[curveRoad.points.length - 1],
|
|
|
|
- line1
|
|
|
|
- );
|
|
|
|
|
|
+ let points1 = mathUtil.RectangleVertex(curveRoad.points[i - 1], curveRoad.points[i], (newWidth + midDivideWidth / 2) * coordinate.ratio);
|
|
|
|
+ line1 = mathUtil.createLine1(points1.rightEdgeStart, points1.rightEdgeEnd);
|
|
|
|
+ let rightJoin = mathUtil.getJoinLinePoint(curveRoad.points[curveRoad.points.length - 1], line1);
|
|
rightCurveEdge.end = JSON.parse(JSON.stringify(rightJoin));
|
|
rightCurveEdge.end = JSON.parse(JSON.stringify(rightJoin));
|
|
- rightCurveEdge.points[rightCurveEdge.points.length - 1] = JSON.parse(
|
|
|
|
- JSON.stringify(rightJoin)
|
|
|
|
- );
|
|
|
|
|
|
+ rightCurveEdge.points[rightCurveEdge.points.length - 1] = JSON.parse(JSON.stringify(rightJoin));
|
|
} else {
|
|
} else {
|
|
- if (
|
|
|
|
- mathUtil.Angle(
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- curveRoad.points[i - 1],
|
|
|
|
- curveRoad.points[i + 1]
|
|
|
|
- ) > Constant.maxAngle
|
|
|
|
- ) {
|
|
|
|
- let rightJoin = mathUtil.getJoinLinePoint(
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- line1
|
|
|
|
- );
|
|
|
|
|
|
+ if (mathUtil.Angle(curveRoad.points[i], curveRoad.points[i - 1], curveRoad.points[i + 1]) > Constant.maxAngle) {
|
|
|
|
+ let rightJoin = mathUtil.getJoinLinePoint(curveRoad.points[i], line1);
|
|
rightCurveEdge.points[i] = JSON.parse(JSON.stringify(rightJoin));
|
|
rightCurveEdge.points[i] = JSON.parse(JSON.stringify(rightJoin));
|
|
} else {
|
|
} else {
|
|
- let points1 = mathUtil.RectangleVertex(
|
|
|
|
- curveRoad.points[i - 1],
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- (newWidth + midDivideWidth / 2) * coordinate.ratio
|
|
|
|
- );
|
|
|
|
- line1 = mathUtil.createLine1(
|
|
|
|
- points1.rightEdgeStart,
|
|
|
|
- points1.rightEdgeEnd
|
|
|
|
- );
|
|
|
|
- let points2 = mathUtil.RectangleVertex(
|
|
|
|
- curveRoad.points[i],
|
|
|
|
- curveRoad.points[i + 1],
|
|
|
|
- (newWidth + midDivideWidth / 2) * coordinate.ratio
|
|
|
|
- );
|
|
|
|
- line2 = mathUtil.createLine1(
|
|
|
|
- points2.rightEdgeStart,
|
|
|
|
- points2.rightEdgeEnd
|
|
|
|
- );
|
|
|
|
|
|
+ let points1 = mathUtil.RectangleVertex(curveRoad.points[i - 1], curveRoad.points[i], (newWidth + midDivideWidth / 2) * coordinate.ratio);
|
|
|
|
+ line1 = mathUtil.createLine1(points1.rightEdgeStart, points1.rightEdgeEnd);
|
|
|
|
+ let points2 = mathUtil.RectangleVertex(curveRoad.points[i], curveRoad.points[i + 1], (newWidth + midDivideWidth / 2) * coordinate.ratio);
|
|
|
|
+ line2 = mathUtil.createLine1(points2.rightEdgeStart, points2.rightEdgeEnd);
|
|
let rightJoin = mathUtil.getIntersectionPoint(line1, line2);
|
|
let rightJoin = mathUtil.getIntersectionPoint(line1, line2);
|
|
rightCurveEdge.points[i] = JSON.parse(JSON.stringify(rightJoin));
|
|
rightCurveEdge.points[i] = JSON.parse(JSON.stringify(rightJoin));
|
|
}
|
|
}
|
|
@@ -1173,22 +930,16 @@ export default class CurveRoadService extends RoadService {
|
|
|
|
|
|
if (curveRoad.way == Constant.oneWay) {
|
|
if (curveRoad.way == Constant.oneWay) {
|
|
for (let i = 0; i < curveRoad.singleLanes.length; ++i) {
|
|
for (let i = 0; i < curveRoad.singleLanes.length; ++i) {
|
|
- let curveLine = lineService.createCurveLineByPoints(
|
|
|
|
- curveRoad.singleLanes[i]
|
|
|
|
- );
|
|
|
|
|
|
+ let curveLine = lineService.createCurveLineByPoints(curveRoad.singleLanes[i]);
|
|
curveLine.setStyle(VectorStyle.SingleDashedLine);
|
|
curveLine.setStyle(VectorStyle.SingleDashedLine);
|
|
}
|
|
}
|
|
} else if (curveRoad.way == Constant.twoWay) {
|
|
} else if (curveRoad.way == Constant.twoWay) {
|
|
for (let i = 0; i < curveRoad.leftLanes.length; ++i) {
|
|
for (let i = 0; i < curveRoad.leftLanes.length; ++i) {
|
|
- let leftCurveLine = lineService.createCurveLineByPoints(
|
|
|
|
- curveRoad.leftLanes[i]
|
|
|
|
- );
|
|
|
|
|
|
+ let leftCurveLine = lineService.createCurveLineByPoints(curveRoad.leftLanes[i]);
|
|
leftCurveLine.setStyle(VectorStyle.SingleDashedLine);
|
|
leftCurveLine.setStyle(VectorStyle.SingleDashedLine);
|
|
}
|
|
}
|
|
for (let i = 0; i < curveRoad.rightLanes.length; ++i) {
|
|
for (let i = 0; i < curveRoad.rightLanes.length; ++i) {
|
|
- let rightCurveLine = lineService.createCurveLineByPoints(
|
|
|
|
- curveRoad.rightLanes[i]
|
|
|
|
- );
|
|
|
|
|
|
+ let rightCurveLine = lineService.createCurveLineByPoints(curveRoad.rightLanes[i]);
|
|
rightCurveLine.setStyle(VectorStyle.SingleDashedLine);
|
|
rightCurveLine.setStyle(VectorStyle.SingleDashedLine);
|
|
}
|
|
}
|
|
// let leftMidDivide = lineService.createCurveLineByPoints(
|
|
// let leftMidDivide = lineService.createCurveLineByPoints(
|
|
@@ -1204,6 +955,159 @@ export default class CurveRoadService extends RoadService {
|
|
mid.setStyle(VectorStyle.SingleDashedLine);
|
|
mid.setStyle(VectorStyle.SingleDashedLine);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ initCurveRoadWidthTipsPos(curveRoad) {
|
|
|
|
+ let curveLeftEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
|
|
|
|
+ let curveRightEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
|
|
|
|
+ let roadStartPoint = dataService.getCurveRoadPoint(curveRoad.startId);
|
|
|
|
+ let roadEndPoint = dataService.getCurveRoadPoint(curveRoad.endId);
|
|
|
|
+ let roadInfo = {
|
|
|
|
+ start: {
|
|
|
|
+ x: roadStartPoint.x,
|
|
|
|
+ y: roadStartPoint.y,
|
|
|
|
+ },
|
|
|
|
+ end: {
|
|
|
|
+ x: roadEndPoint.x,
|
|
|
|
+ y: roadEndPoint.y,
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ let roadLine = mathUtil.createLine1(dataService.getCurveRoadPoint(curveRoad.startId), dataService.getCurveRoadPoint(curveRoad.endId));
|
|
|
|
+ let roadLineCrossPoint = mathUtil.getLineEndPointPos(roadInfo.start, roadInfo.end);
|
|
|
|
+ let CrossPointStartDistance = mathUtil.getDistance(roadStartPoint, roadLineCrossPoint);
|
|
|
|
+ let leftEdgeDistance = mathUtil.getDistance(curveLeftEdge.start, curveLeftEdge.end);
|
|
|
|
+ let righttEdgeDistance = mathUtil.getDistance(curveRightEdge.start, curveRightEdge.end);
|
|
|
|
+ if (CrossPointStartDistance > leftEdgeDistance || CrossPointStartDistance > righttEdgeDistance) {
|
|
|
|
+ let satrtEdgeLine = mathUtil.createLine1(curveLeftEdge.start, curveRightEdge.start);
|
|
|
|
+ let endEdgeLine = mathUtil.createLine1(curveLeftEdge.end, curveRightEdge.end);
|
|
|
|
+ let satrtEdgeCrossPoint = mathUtil.getIntersectionPoint(satrtEdgeLine, roadLine);
|
|
|
|
+ let endEdgeCrossPoint = mathUtil.getIntersectionPoint(endEdgeLine, roadLine);
|
|
|
|
+
|
|
|
|
+ roadLineCrossPoint = mathUtil.getLineEndPointPos(satrtEdgeCrossPoint, endEdgeCrossPoint);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let leftEdgeLine = mathUtil.createLine1(curveLeftEdge.start, curveLeftEdge.end);
|
|
|
|
+ let rightEdgeLine = mathUtil.createLine1(curveRightEdge.start, curveRightEdge.end);
|
|
|
|
+ let leftEdgePoint = mathUtil.getJoinLinePoint(roadLineCrossPoint, leftEdgeLine);
|
|
|
|
+ let rightEdgePoint = mathUtil.getJoinLinePoint(roadLineCrossPoint, rightEdgeLine);
|
|
|
|
+
|
|
|
|
+ let edgeLine = mathUtil.createLine1(leftEdgePoint, rightEdgePoint);
|
|
|
|
+ let roadWidthTipsPos = [];
|
|
|
|
+ if (curveRoad.way == Constant.oneWay) {
|
|
|
|
+ //单向
|
|
|
|
+ if (curveRoad.singleLanes.length) {
|
|
|
|
+ //单向多车道
|
|
|
|
+ let crossList = [];
|
|
|
|
+ for (let i = 0; i < curveRoad.singleLanes.length; i++) {
|
|
|
|
+ let crossLine = mathUtil.createLine1(curveRoad.singleLanes[i].start, curveRoad.singleLanes[i].end);
|
|
|
|
+ crossList.push(crossLine);
|
|
|
|
+ }
|
|
|
|
+ for (let i = 0; i < crossList.length; i++) {
|
|
|
|
+ if (i == 0) {
|
|
|
|
+ //第一个位置
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: rightEdgePoint,
|
|
|
|
+ end: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i]),
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ //以此类推
|
|
|
|
+ let middleEdgePoint1 = mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i - 1]);
|
|
|
|
+ let middleEdgePoint2 = mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i]);
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: middleEdgePoint1,
|
|
|
|
+ end: middleEdgePoint2,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //最后一个位置
|
|
|
|
+
|
|
|
|
+ let a = mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[crossList.length - 1]);
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: a,
|
|
|
|
+ end: leftEdgePoint,
|
|
|
|
+ });
|
|
|
|
+ curveRoad.setRoadWidthTipsPos(roadWidthTipsPos);
|
|
|
|
+ } else {
|
|
|
|
+ //单向单车道
|
|
|
|
+ roadWidthTipsPos.push({ start: leftEdgePoint, end: rightEdgePoint });
|
|
|
|
+ curveRoad.setRoadWidthTipsPos(roadWidthTipsPos);
|
|
|
|
+ }
|
|
|
|
+ } else if (curveRoad.way == Constant.twoWay) {
|
|
|
|
+ //双单车道
|
|
|
|
+ let leftMidDivideLine = mathUtil.createLine1(curveRoad.midDivide.leftMidDivide.start, curveRoad.midDivide.leftMidDivide.end);
|
|
|
|
+ let rightMidDividePointLine = mathUtil.createLine1(curveRoad.midDivide.rightMidDivide.start, curveRoad.midDivide.rightMidDivide.end);
|
|
|
|
+ let leftMidDividePoint = mathUtil.getJoinLinePoint(roadLineCrossPoint, leftMidDivideLine);
|
|
|
|
+ let rightMidDividePoint = mathUtil.getJoinLinePoint(roadLineCrossPoint, rightMidDividePointLine);
|
|
|
|
+ if (curveRoad.leftLanes.length) {
|
|
|
|
+ let crossList = [];
|
|
|
|
+ for (let i = 0; i < curveRoad.leftLanes.length; i++) {
|
|
|
|
+ let crossLine = mathUtil.createLine1(curveRoad.leftLanes[i].start, curveRoad.leftLanes[i].end);
|
|
|
|
+ crossList.push(crossLine);
|
|
|
|
+ }
|
|
|
|
+ for (let i = 0; i < crossList.length; i++) {
|
|
|
|
+ if (i == 0) {
|
|
|
|
+ //第一个位置
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: leftMidDividePoint,
|
|
|
|
+ end: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i]),
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ //以此类推
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i - 1]),
|
|
|
|
+ end: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i]),
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //最后一个位置
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[crossList.length - 1]),
|
|
|
|
+ end: leftEdgePoint,
|
|
|
|
+ });
|
|
|
|
+ curveRoad.setRoadWidthTipsPos(roadWidthTipsPos);
|
|
|
|
+ } else {
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: leftEdgePoint,
|
|
|
|
+ end: leftMidDividePoint,
|
|
|
|
+ });
|
|
|
|
+ curveRoad.setRoadWidthTipsPos(roadWidthTipsPos);
|
|
|
|
+ }
|
|
|
|
+ if (curveRoad.rightLanes.length) {
|
|
|
|
+ let crossList = [];
|
|
|
|
+ for (let i = 0; i < curveRoad.rightLanes.length; i++) {
|
|
|
|
+ let crossLine = mathUtil.createLine1(curveRoad.rightLanes[i].start, curveRoad.rightLanes[i].end);
|
|
|
|
+ crossList.push(crossLine);
|
|
|
|
+ }
|
|
|
|
+ for (let i = 0; i < crossList.length; i++) {
|
|
|
|
+ if (i == 0) {
|
|
|
|
+ //第一个位置
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: rightMidDividePoint,
|
|
|
|
+ end: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i]),
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ //以此类推
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i - 1]),
|
|
|
|
+ end: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i]),
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //最后一个位置
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[crossList.length - 1]),
|
|
|
|
+ end: rightEdgePoint,
|
|
|
|
+ });
|
|
|
|
+ curveRoad.setRoadWidthTipsPos(roadWidthTipsPos);
|
|
|
|
+ } else {
|
|
|
|
+ roadWidthTipsPos.push({
|
|
|
|
+ start: rightMidDividePoint,
|
|
|
|
+ end: rightEdgePoint,
|
|
|
|
+ });
|
|
|
|
+ curveRoad.setRoadWidthTipsPos(roadWidthTipsPos);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
const curveRoadService = new CurveRoadService();
|
|
const curveRoadService = new CurveRoadService();
|