|
@@ -9,6 +9,8 @@ import { mathUtil } from "../Util/MathUtil.js";
|
|
|
import { uiService } from "./UIService.js";
|
|
|
import { addLine } from "../Controls/AddLine.js";
|
|
|
import Constant from "../Constant.js";
|
|
|
+import RoadStructure from "../enum/RoadStructure.js";
|
|
|
+import Settings from "../Settings";
|
|
|
|
|
|
export default class LineService {
|
|
|
constructor() {}
|
|
@@ -23,6 +25,12 @@ export default class LineService {
|
|
|
if (category) {
|
|
|
line.setCategory(category);
|
|
|
}
|
|
|
+ if (Settings.selectSVGType == RoadStructure.ZebraCrossing) {
|
|
|
+ line.setCategory(Settings.selectSVGType);
|
|
|
+ line.setZebraCrossStyle()
|
|
|
+ line.setZebraCrossLineWeight(Settings.zebraCrossLineWeight)
|
|
|
+ line.setZebraCrossLineSpace(Settings.zebraCrosslineSpace)
|
|
|
+ }
|
|
|
start.setPointParent(line.vectorId, "start");
|
|
|
end.setPointParent(line.vectorId, "end");
|
|
|
dataService.addPoint(start);
|
|
@@ -52,10 +60,7 @@ export default class LineService {
|
|
|
for (let key in points) {
|
|
|
let point = dataService.getPoint(key);
|
|
|
let category = point.getCategory();
|
|
|
- if (
|
|
|
- category == VectorCategory.Point.BasePoint ||
|
|
|
- category == VectorCategory.Point.TestBasePoint
|
|
|
- ) {
|
|
|
+ if (category == VectorCategory.Point.BasePoint || category == VectorCategory.Point.TestBasePoint) {
|
|
|
dataService.deletePoint(key);
|
|
|
}
|
|
|
}
|
|
@@ -85,10 +90,7 @@ export default class LineService {
|
|
|
let lines = dataService.getLines();
|
|
|
for (let key in lines) {
|
|
|
const line = dataService.getLine(key);
|
|
|
- if (
|
|
|
- (line.startId == pointId1 && line.endId == pointId2) ||
|
|
|
- (line.endId == pointId1 && line.startId == pointId2)
|
|
|
- ) {
|
|
|
+ if ((line.startId == pointId1 && line.endId == pointId2) || (line.endId == pointId1 && line.startId == pointId2)) {
|
|
|
return key;
|
|
|
}
|
|
|
}
|
|
@@ -109,20 +111,12 @@ export default class LineService {
|
|
|
|
|
|
/******************************************************************************曲线**************************************************************************************/
|
|
|
createCurveLine(startPosition, endPosition, vectorId) {
|
|
|
- if (
|
|
|
- !startPosition ||
|
|
|
- !endPosition ||
|
|
|
- mathUtil.equalPoint(startPosition, endPosition)
|
|
|
- ) {
|
|
|
+ if (!startPosition || !endPosition || mathUtil.equalPoint(startPosition, endPosition)) {
|
|
|
return null;
|
|
|
}
|
|
|
let startPoint = curvePointService.create(startPosition);
|
|
|
let endPoint = curvePointService.create(endPosition);
|
|
|
- let curveLine = new CurveLine(
|
|
|
- startPoint.vectorId,
|
|
|
- endPoint.vectorId,
|
|
|
- vectorId
|
|
|
- );
|
|
|
+ let curveLine = new CurveLine(startPoint.vectorId, endPoint.vectorId, vectorId);
|
|
|
|
|
|
startPoint.setPointParent(curveLine.vectorId);
|
|
|
startPoint.setIndex(0);
|
|
@@ -144,11 +138,7 @@ export default class LineService {
|
|
|
}
|
|
|
|
|
|
createCurveLineByPointIds(curvePoints, vectorId) {
|
|
|
- let curveLine = new CurveLine(
|
|
|
- curvePoints[0].vectorId,
|
|
|
- curvePoints[curvePoints.length - 1].vectorId,
|
|
|
- vectorId
|
|
|
- );
|
|
|
+ let curveLine = new CurveLine(curvePoints[0].vectorId, curvePoints[curvePoints.length - 1].vectorId, vectorId);
|
|
|
curveLine.points = [];
|
|
|
for (let i = 0; i < curvePoints.length; ++i) {
|
|
|
curveLine.points[i] = dataService.getCurvePoint(curvePoints[i].vectorId);
|
|
@@ -167,11 +157,7 @@ export default class LineService {
|
|
|
curvePoint.setIndex(i);
|
|
|
curvePoints.push(curvePoint);
|
|
|
}
|
|
|
- let curveLine = new CurveLine(
|
|
|
- curvePoints[0].vectorId,
|
|
|
- curvePoints[curvePoints.length - 1].vectorId,
|
|
|
- vectorId
|
|
|
- );
|
|
|
+ let curveLine = new CurveLine(curvePoints[0].vectorId, curvePoints[curvePoints.length - 1].vectorId, vectorId);
|
|
|
curveLine.points = curvePoints;
|
|
|
for (let i = 0; i < curvePoints.length; ++i) {
|
|
|
curvePoints[i].setIndex(i);
|
|
@@ -212,10 +198,7 @@ export default class LineService {
|
|
|
newCurveLine.setStyle(curveLine.style);
|
|
|
}
|
|
|
|
|
|
- mathUtil.clonePoint(
|
|
|
- newCurveLine.points[1],
|
|
|
- uiService.getNewPositionForPop(curveLine.points[1])
|
|
|
- );
|
|
|
+ mathUtil.clonePoint(newCurveLine.points[1], uiService.getNewPositionForPop(curveLine.points[1]));
|
|
|
newCurveLine.points[1].setIndex(curveLine.points[1].getIndex());
|
|
|
|
|
|
for (let i = 2; i < curveLine.points.length - 1; ++i) {
|
|
@@ -225,9 +208,7 @@ export default class LineService {
|
|
|
newPoint.setIndex(curveLine.points[i].getIndex());
|
|
|
newCurveLine.points.splice(i, 0, newPoint);
|
|
|
}
|
|
|
- newCurveLine.points[newCurveLine.points.length - 1].setIndex(
|
|
|
- curveLine.points[curveLine.points.length - 1].getIndex()
|
|
|
- );
|
|
|
+ newCurveLine.points[newCurveLine.points.length - 1].setIndex(curveLine.points[curveLine.points.length - 1].getIndex());
|
|
|
newCurveLine.curves = mathUtil.getCurvesByPoints(newCurveLine.points);
|
|
|
return newCurveLine.vectorId;
|
|
|
}
|
|
@@ -240,22 +221,17 @@ export default class LineService {
|
|
|
curveLine.points.shift();
|
|
|
curveLine.startId = curveLine.points[0].vectorId;
|
|
|
for (let j = 0; j < curveLine.points.length; ++j) {
|
|
|
- let _curvePoint = dataService.getCurvePoint(
|
|
|
- curveLine.points[j].vectorId
|
|
|
- );
|
|
|
+ let _curvePoint = dataService.getCurvePoint(curveLine.points[j].vectorId);
|
|
|
const index = _curvePoint.getIndex();
|
|
|
_curvePoint.setIndex(index - 1);
|
|
|
}
|
|
|
} else if (i == curveLine.points.length - 1) {
|
|
|
curveLine.points.pop();
|
|
|
- curveLine.endId =
|
|
|
- curveLine.points[curveLine.points.length - 1].vectorId;
|
|
|
+ curveLine.endId = curveLine.points[curveLine.points.length - 1].vectorId;
|
|
|
} else {
|
|
|
curveLine.points.splice(i, 1);
|
|
|
for (let j = i; j < curveLine.points.length; ++j) {
|
|
|
- let _curvePoint = dataService.getCurvePoint(
|
|
|
- curveLine.points[j].vectorId
|
|
|
- );
|
|
|
+ let _curvePoint = dataService.getCurvePoint(curveLine.points[j].vectorId);
|
|
|
const index = _curvePoint.getIndex();
|
|
|
_curvePoint.setIndex(index - 1);
|
|
|
}
|