|
@@ -19,54 +19,78 @@ export default class EdgeService {
|
|
|
return line;
|
|
|
}
|
|
|
|
|
|
- //计算默认的edge
|
|
|
+ // //计算默认的edge
|
|
|
+ // computerDefaultEdge(roadId) {
|
|
|
+ // // console.log("开始执行computerDefaultEdge");
|
|
|
+ // let road = dataService.getRoad(roadId);
|
|
|
+ // let line = roadService.getMidLine(road);
|
|
|
+
|
|
|
+ // let lines = mathUtil.getParallelLineForDistance(line, road.width / 2);
|
|
|
+ // let startPoint = dataService.getPoint(road.startId);
|
|
|
+ // let endPoint = dataService.getPoint(road.endId);
|
|
|
+
|
|
|
+ // let leftEdge = dataService.getEdge(road.leftEdgeId);
|
|
|
+ // let rightEdge = dataService.getEdge(road.rightEdgeId);
|
|
|
+
|
|
|
+ // let point = null;
|
|
|
+ // let points = [];
|
|
|
+
|
|
|
+ // //先计算start部分
|
|
|
+ // point = startPoint;
|
|
|
+ // points.push(endPoint);
|
|
|
+ // points.push(startPoint);
|
|
|
+ // let point1 = mathUtil.getJoinLinePoint(point, lines.line1);
|
|
|
+ // let point2 = mathUtil.getJoinLinePoint(point, lines.line2);
|
|
|
+ // points[2] = point1;
|
|
|
+
|
|
|
+ // if (mathUtil.isClockwise(points)) {
|
|
|
+ // mathUtil.clonePoint(rightEdge.start, point1);
|
|
|
+ // mathUtil.clonePoint(leftEdge.start, point2);
|
|
|
+ // } else {
|
|
|
+ // mathUtil.clonePoint(leftEdge.start, point1);
|
|
|
+ // mathUtil.clonePoint(rightEdge.start, point2);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // //再计算end部分
|
|
|
+ // points = [];
|
|
|
+ // point = endPoint;
|
|
|
+ // points.push(startPoint);
|
|
|
+ // points.push(endPoint);
|
|
|
+ // point1 = mathUtil.getJoinLinePoint(point, lines.line1);
|
|
|
+ // point2 = mathUtil.getJoinLinePoint(point, lines.line2);
|
|
|
+ // points[2] = point1;
|
|
|
+
|
|
|
+ // if (mathUtil.isClockwise(points)) {
|
|
|
+ // mathUtil.clonePoint(leftEdge.end, point1);
|
|
|
+ // mathUtil.clonePoint(rightEdge.end, point2);
|
|
|
+ // } else {
|
|
|
+ // mathUtil.clonePoint(rightEdge.end, point1);
|
|
|
+ // mathUtil.clonePoint(leftEdge.end, point2);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
computerDefaultEdge(roadId) {
|
|
|
- // console.log("开始执行computerDefaultEdge");
|
|
|
let road = dataService.getRoad(roadId);
|
|
|
- let line = roadService.getMidLine(road);
|
|
|
-
|
|
|
- let lines = mathUtil.getParallelLineForDistance(line, road.width / 2);
|
|
|
let startPoint = dataService.getPoint(road.startId);
|
|
|
let endPoint = dataService.getPoint(road.endId);
|
|
|
-
|
|
|
let leftEdge = dataService.getEdge(road.leftEdgeId);
|
|
|
let rightEdge = dataService.getEdge(road.rightEdgeId);
|
|
|
|
|
|
- let point = null;
|
|
|
- let points = [];
|
|
|
-
|
|
|
- //先计算start部分
|
|
|
- point = startPoint;
|
|
|
- points.push(endPoint);
|
|
|
- points.push(startPoint);
|
|
|
- let point1 = mathUtil.getJoinLinePoint(point, lines.line1);
|
|
|
- let point2 = mathUtil.getJoinLinePoint(point, lines.line2);
|
|
|
- points[2] = point1;
|
|
|
-
|
|
|
- if (mathUtil.isClockwise(points)) {
|
|
|
- mathUtil.clonePoint(rightEdge.start, point1);
|
|
|
- mathUtil.clonePoint(leftEdge.start, point2);
|
|
|
- } else {
|
|
|
- mathUtil.clonePoint(leftEdge.start, point1);
|
|
|
- mathUtil.clonePoint(rightEdge.start, point2);
|
|
|
- }
|
|
|
-
|
|
|
- //再计算end部分
|
|
|
- points = [];
|
|
|
- point = endPoint;
|
|
|
- points.push(startPoint);
|
|
|
- points.push(endPoint);
|
|
|
- point1 = mathUtil.getJoinLinePoint(point, lines.line1);
|
|
|
- point2 = mathUtil.getJoinLinePoint(point, lines.line2);
|
|
|
- points[2] = point1;
|
|
|
-
|
|
|
- if (mathUtil.isClockwise(points)) {
|
|
|
- mathUtil.clonePoint(leftEdge.end, point1);
|
|
|
- mathUtil.clonePoint(rightEdge.end, point2);
|
|
|
- } else {
|
|
|
- mathUtil.clonePoint(rightEdge.end, point1);
|
|
|
- mathUtil.clonePoint(leftEdge.end, point2);
|
|
|
- }
|
|
|
+ const line = roadService.getMidLine(road);
|
|
|
+ const leftWidth = mathUtil.getDisForPoinLine(leftEdge.start, line);
|
|
|
+ const rightWidth = mathUtil.getDisForPoinLine(rightEdge.start, line);
|
|
|
+
|
|
|
+ let edgePoints = mathUtil.RectangleVertex(
|
|
|
+ startPoint,
|
|
|
+ endPoint,
|
|
|
+ leftWidth * 2
|
|
|
+ );
|
|
|
+ mathUtil.clonePoint(leftEdge.start, edgePoints.leftEdgeStart);
|
|
|
+ mathUtil.clonePoint(leftEdge.end, edgePoints.leftEdgeEnd);
|
|
|
+
|
|
|
+ edgePoints = mathUtil.RectangleVertex(startPoint, endPoint, rightWidth * 2);
|
|
|
+ mathUtil.clonePoint(rightEdge.start, edgePoints.rightEdgeStart);
|
|
|
+ mathUtil.clonePoint(rightEdge.end, edgePoints.rightEdgeEnd);
|
|
|
}
|
|
|
|
|
|
//单独的墙的一端
|
|
@@ -797,7 +821,7 @@ export default class EdgeService {
|
|
|
if (Object.keys(parent).length == 1) {
|
|
|
dir = roadService.getDirction(pointId, Object.keys(parent)[0]);
|
|
|
this.updateDefaultEdge(Object.keys(parent)[0], dir);
|
|
|
- roadService.setLanes(Object.keys(parent)[0], dir);
|
|
|
+ roadService.setLanes(Object.keys(parent)[0]);
|
|
|
roadService.setMidDivide(Object.keys(parent)[0], dir);
|
|
|
} else if (Object.keys(parent).length == 2) {
|
|
|
this.updateEdgeForTwoRoad(Object.keys(parent)[0], Object.keys(parent)[1]);
|
|
@@ -844,18 +868,18 @@ export default class EdgeService {
|
|
|
}
|
|
|
this.updateSingleEdgeForTwoRoad(startRoadId, endRoadId);
|
|
|
dir = roadService.getDirction(pointId, startRoadId);
|
|
|
- roadService.setLanes(startRoadId, dir);
|
|
|
+ roadService.setLanes(startRoadId);
|
|
|
roadService.setMidDivide(startRoadId, dir);
|
|
|
dir = roadService.getDirction(pointId, endRoadId);
|
|
|
- roadService.setLanes(endRoadId, dir);
|
|
|
+ roadService.setLanes(endRoadId);
|
|
|
roadService.setMidDivide(endRoadId, dir);
|
|
|
|
|
|
this.updateSingleEdgeForTwoRoad(endRoadId, _startRoadId);
|
|
|
dir = roadService.getDirction(pointId, endRoadId);
|
|
|
- roadService.setLanes(endRoadId, dir);
|
|
|
+ roadService.setLanes(endRoadId);
|
|
|
roadService.setMidDivide(endRoadId, dir);
|
|
|
dir = roadService.getDirction(pointId, _startRoadId);
|
|
|
- roadService.setLanes(_startRoadId, dir);
|
|
|
+ roadService.setLanes(_startRoadId);
|
|
|
roadService.setMidDivide(_startRoadId, dir);
|
|
|
} else {
|
|
|
console.error(
|