|
@@ -1,6 +1,7 @@
|
|
|
import { mathUtil } from "../Util/MathUtil";
|
|
|
import { dataService } from "../Service/DataService";
|
|
|
import { textService } from "../Service/TextService";
|
|
|
+import Constant from "../Constant";
|
|
|
|
|
|
export default class HistoryUtil {
|
|
|
constructor() {}
|
|
@@ -17,7 +18,8 @@ export default class HistoryUtil {
|
|
|
if (
|
|
|
point1.x == point2.x &&
|
|
|
point1.y == point2.y &&
|
|
|
- JSON.stringify(point1.parent) == JSON.stringify(point2.parent)
|
|
|
+ JSON.stringify(point1.parent) == JSON.stringify(point2.parent) &&
|
|
|
+ point1.category == point2.category
|
|
|
) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -40,7 +42,8 @@ export default class HistoryUtil {
|
|
|
isDifferentForCircles(circle1, circle2) {
|
|
|
if (
|
|
|
mathUtil.equalPoint(circle1.center, circle2.center) &&
|
|
|
- circle1.radius == circle2.radius
|
|
|
+ circle1.radius == circle2.radius &&
|
|
|
+ circle1.color == circle2.color
|
|
|
) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -59,6 +62,17 @@ export default class HistoryUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ isDifferentForMagnifiers(magnifier1, magnifier2) {
|
|
|
+ if (
|
|
|
+ mathUtil.equalPoint(magnifier1.position, magnifier2.position) &&
|
|
|
+ magnifier1.photoUrl == magnifier2.photoUrl
|
|
|
+ ) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
isDifferentForSVGs(svg1, svg2) {
|
|
|
if (
|
|
|
mathUtil.equalPoint(svg1.center, svg2.center) &&
|
|
@@ -70,28 +84,95 @@ export default class HistoryUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // // road2赋值给road1
|
|
|
- // assignRoadFromRoad(road1, road2) {
|
|
|
- // const roadInfo = {};
|
|
|
- // roadInfo.vectorId = road1.vectorId;
|
|
|
- // roadInfo.start = road2.startId;
|
|
|
- // roadInfo.end = road2.endId;
|
|
|
- // this.setRoadInfo(roadInfo);
|
|
|
- // }
|
|
|
+ isDifferentForRoadPoints(roadPoint1, roadPoint2) {
|
|
|
+ if (
|
|
|
+ mathUtil.equalPoint(roadPoint1, roadPoint2) &&
|
|
|
+ JSON.stringify(roadPoint1.parent) == JSON.stringify(roadPoint2.parent)
|
|
|
+ ) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ isDifferentForRoadEdges(roadEdge1, roadEdge2) {
|
|
|
+ if (
|
|
|
+ mathUtil.equalPoint(roadEdge1.start, roadEdge2.start) &&
|
|
|
+ mathUtil.equalPoint(roadEdge1.end, roadEdge2.end) &&
|
|
|
+ roadEdge1.parent == roadEdge2.parent
|
|
|
+ ) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ isDifferentForRoads(road1, road2) {
|
|
|
+ if (
|
|
|
+ road1.startId == road2.startId &&
|
|
|
+ road1.endId == road2.endId &&
|
|
|
+ road1.leftEdgeId == road2.leftEdgeId &&
|
|
|
+ road1.rightEdgeId == road2.rightEdgeId &&
|
|
|
+ road1.way == road2.way
|
|
|
+ ) {
|
|
|
+ if (road1.way == Constant.oneWay) {
|
|
|
+ if (
|
|
|
+ road1.singleRoadWidth == road2.singleRoadWidth &&
|
|
|
+ road1.singleRoadDrivewayCount == road2.singleRoadDrivewayCount
|
|
|
+ ) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } else if (road1.way == Constant.twoWay) {
|
|
|
+ if (
|
|
|
+ road1.leftWidth == road2.leftWidth &&
|
|
|
+ road1.rightWidth == road2.rightWidth &&
|
|
|
+ road1.leftDrivewayCount == road2.leftDrivewayCount &&
|
|
|
+ road1.rightDrivewayCount == road2.rightDrivewayCount &&
|
|
|
+ road1.midDivide.midDivideWidth == road2.midDivide.midDivideWidth
|
|
|
+ ) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ isDifferentForCrossPoints(crossPoint1, crossPoint2) {
|
|
|
+ if (
|
|
|
+ mathUtil.equalPoint(crossPoint1, crossPoint2) &&
|
|
|
+ mathUtil.equalPoint(crossPoint1.extremePoint, crossPoint2.extremePoint) &&
|
|
|
+ crossPoint1.edgeInfo1.id == crossPoint2.edgeInfo1.id &&
|
|
|
+ crossPoint1.edgeInfo1.dir == crossPoint2.edgeInfo1.dir &&
|
|
|
+ crossPoint1.edgeInfo2.id == crossPoint2.edgeInfo2.id &&
|
|
|
+ crossPoint1.edgeInfo2.dir == crossPoint2.edgeInfo2.dir
|
|
|
+ ) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
assignPointFromPoint(point1, point2) {
|
|
|
const pointInfo = {};
|
|
|
pointInfo.vectorId = point1.vectorId;
|
|
|
pointInfo.position = { x: point2.x, y: point2.y };
|
|
|
pointInfo.parent = JSON.parse(JSON.stringify(point2.parent));
|
|
|
+ pointInfo.category = point2.category;
|
|
|
this.setPointInfo(pointInfo);
|
|
|
}
|
|
|
|
|
|
assignLineFromLine(line1, line2) {
|
|
|
const lineInfo = {};
|
|
|
lineInfo.vectorId = line1.vectorId;
|
|
|
- lineInfo.start = line2.startId;
|
|
|
- lineInfo.end = line2.endId;
|
|
|
+ lineInfo.start = line2.start;
|
|
|
+ lineInfo.end = line2.end;
|
|
|
lineInfo.category = line2.category;
|
|
|
this.setLineInfo(lineInfo);
|
|
|
}
|
|
@@ -101,6 +182,8 @@ export default class HistoryUtil {
|
|
|
circleInfo.vectorId = circle1.vectorId;
|
|
|
circleInfo.center = circle2.center;
|
|
|
circleInfo.radius = circle2.radius;
|
|
|
+ circleInfo.points = JSON.parse(JSON.stringify(circle2.points));
|
|
|
+ circleInfo.color = circle2.color;
|
|
|
this.setCircleInfo(circleInfo);
|
|
|
}
|
|
|
|
|
@@ -112,6 +195,17 @@ export default class HistoryUtil {
|
|
|
this.setTextInfo(textInfo);
|
|
|
}
|
|
|
|
|
|
+ assignMagnifierFromMagnifier(magnifier1, magnifier2) {
|
|
|
+ const magnifierInfo = {};
|
|
|
+ magnifierInfo.vectorId = magnifier1.vectorId;
|
|
|
+ magnifierInfo.photoUrl = magnifier2.photoUrl;
|
|
|
+ magnifierInfo.position = JSON.parse(JSON.stringify(magnifier2.position));
|
|
|
+ magnifierInfo.popPosition = JSON.parse(
|
|
|
+ JSON.stringify(magnifier2.popPosition)
|
|
|
+ );
|
|
|
+ this.setMagnifierInfo(magnifierInfo);
|
|
|
+ }
|
|
|
+
|
|
|
assignSVGFromSVG(svg1, svg2) {
|
|
|
const svgInfo = {};
|
|
|
svgInfo.vectorId = svg1.vectorId;
|
|
@@ -120,11 +214,74 @@ export default class HistoryUtil {
|
|
|
this.setSVGInfo(svgInfo);
|
|
|
}
|
|
|
|
|
|
+ assignRoadPointFromRoadPoint(roadPoint1, roadPoint2) {
|
|
|
+ const roadPointInfo = {};
|
|
|
+ roadPointInfo.vectorId = roadPoint1.vectorId;
|
|
|
+ roadPointInfo.position = {
|
|
|
+ x: roadPoint2.position.x,
|
|
|
+ y: roadPoint2.position.y,
|
|
|
+ };
|
|
|
+ roadPointInfo.parent = JSON.parse(JSON.stringify(roadPoint2.parent));
|
|
|
+ this.setRoadPointInfo(roadPointInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ assignRoadEdgeFromRoadEdge(roadEdge1, roadEdge2) {
|
|
|
+ const roadEdgeInfo = {};
|
|
|
+ roadEdgeInfo.vectorId = roadEdge1.vectorId;
|
|
|
+ roadEdgeInfo.start = { x: roadEdge2.start.x, y: roadEdge2.start.y };
|
|
|
+ roadEdgeInfo.end = { x: roadEdge2.end.x, y: roadEdge2.end.y };
|
|
|
+ roadEdgeInfo.parent = roadEdge2.parent;
|
|
|
+ this.setRoadEdgeInfo(roadEdgeInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ assignRoadFromRoad(road1, road2) {
|
|
|
+ const roadInfo = {};
|
|
|
+ roadInfo.vectorId = road1.vectorId;
|
|
|
+ roadInfo.startId = road2.startId;
|
|
|
+ roadInfo.endId = road2.endId;
|
|
|
+ roadInfo.leftEdgeId = road2.leftEdgeId;
|
|
|
+ roadInfo.rightEdgeId = road2.rightEdgeId;
|
|
|
+ roadInfo.way = road2.way;
|
|
|
+ if (road2.way == Constant.oneWay) {
|
|
|
+ roadInfo.singleRoadWidth = road2.singleRoadWidth;
|
|
|
+ roadInfo.singleRoadDrivewayCount = road2.singleRoadDrivewayCount;
|
|
|
+ roadInfo.singleLanes = JSON.parse(JSON.stringify(road2.singleLanes));
|
|
|
+ } else if (road2.way == Constant.twoWay) {
|
|
|
+ roadInfo.leftWidth = road2.leftWidth;
|
|
|
+ roadInfo.rightWidth = road2.rightWidth;
|
|
|
+ roadInfo.leftDrivewayCount = road2.leftDrivewayCount;
|
|
|
+ roadInfo.rightDrivewayCount = road2.rightDrivewayCount;
|
|
|
+ roadInfo.midDivide = JSON.parse(JSON.stringify(road2.midDivide));
|
|
|
+ roadInfo.leftLanes = JSON.parse(JSON.stringify(road2.leftLanes));
|
|
|
+ roadInfo.rightLanes = JSON.parse(JSON.stringify(road2.rightLanes));
|
|
|
+ }
|
|
|
+ this.setRoadInfo(roadInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ assignCrossPointFromCrossPoint(crossPoint1, crossPoint2) {
|
|
|
+ const crossPointInfo = {};
|
|
|
+ crossPointInfo.vectorId = crossPoint1.vectorId;
|
|
|
+ crossPointInfo.position = { x: crossPoint2.x, y: crossPoint2.y };
|
|
|
+ crossPointInfo.edgeInfo1 = JSON.parse(
|
|
|
+ JSON.stringify(crossPoint2.edgeInfo1)
|
|
|
+ );
|
|
|
+ crossPointInfo.edgeInfo2 = JSON.parse(
|
|
|
+ JSON.stringify(crossPoint2.edgeInfo2)
|
|
|
+ );
|
|
|
+ crossPointInfo.extremePoint = {
|
|
|
+ x: crossPoint2.extremePoint.x,
|
|
|
+ y: crossPoint2.extremePoint.y,
|
|
|
+ };
|
|
|
+ crossPointInfo.curves = JSON.parse(JSON.stringify(crossPoint2.curves));
|
|
|
+ this.setCrossPointInfo(crossPointInfo);
|
|
|
+ }
|
|
|
+
|
|
|
getDataForPoint(point) {
|
|
|
const data = {};
|
|
|
data.id = point.vectorId;
|
|
|
mathUtil.clonePoint(data, point);
|
|
|
data.parent = JSON.parse(JSON.stringify(point.parent));
|
|
|
+ data.category = point.category;
|
|
|
data.type = point.geoType;
|
|
|
return data;
|
|
|
}
|
|
@@ -134,6 +291,7 @@ export default class HistoryUtil {
|
|
|
data.id = line.vectorId;
|
|
|
data.start = line.startId;
|
|
|
data.end = line.endId;
|
|
|
+ data.category = line.category;
|
|
|
data.type = line.geoType;
|
|
|
return data;
|
|
|
}
|
|
@@ -144,6 +302,8 @@ export default class HistoryUtil {
|
|
|
data.center = {};
|
|
|
mathUtil.clonePoint(data.center, circle.center);
|
|
|
data.radius = circle.radius;
|
|
|
+ data.points = circle.points;
|
|
|
+ data.color = circle.color;
|
|
|
data.type = circle.geoType;
|
|
|
return data;
|
|
|
}
|
|
@@ -158,6 +318,18 @@ export default class HistoryUtil {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ getDataForMagnifier(magnifier) {
|
|
|
+ const data = {};
|
|
|
+ data.id = magnifier.vectorId;
|
|
|
+ data.type = magnifier.geoType;
|
|
|
+ data.position = {};
|
|
|
+ data.popPosition = {};
|
|
|
+ mathUtil.clonePoint(data.position, magnifier.position);
|
|
|
+ mathUtil.clonePoint(data.popPosition, magnifier.popPosition);
|
|
|
+ data.photoUrl = magnifier.photoUrl;
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
getDataForSVG(svg) {
|
|
|
const data = {};
|
|
|
data.id = svg.vectorId;
|
|
@@ -168,17 +340,72 @@ export default class HistoryUtil {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
- // setRoadInfo(roadInfo) {
|
|
|
- // let road = dataService.getRoad(roadInfo.vectorId);
|
|
|
- // road.start = roadInfo.start;
|
|
|
- // road.end = roadInfo.end;
|
|
|
- // return road;
|
|
|
- // }
|
|
|
+ getDataForRoadPoint(roadPoint) {
|
|
|
+ const data = {};
|
|
|
+ data.id = roadPoint.vectorId;
|
|
|
+ data.type = roadPoint.geoType;
|
|
|
+ data.position = {};
|
|
|
+ mathUtil.clonePoint(data.position, roadPoint);
|
|
|
+ data.parent = JSON.parse(JSON.stringify(roadPoint.parent));
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ getDataForRoadEdge(roadEdge) {
|
|
|
+ const data = {};
|
|
|
+ data.id = roadEdge.vectorId;
|
|
|
+ data.type = roadEdge.geoType;
|
|
|
+ data.parent = roadEdge.parent;
|
|
|
+ data.start = {};
|
|
|
+ data.start = JSON.parse(JSON.stringify(roadEdge.start));
|
|
|
+ data.end = {};
|
|
|
+ data.end = JSON.parse(JSON.stringify(roadEdge.end));
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ getDataForRoad(road) {
|
|
|
+ const data = {};
|
|
|
+ data.id = road.vectorId;
|
|
|
+ data.type = road.geoType;
|
|
|
+ data.startId = road.startId;
|
|
|
+ data.endId = road.endId;
|
|
|
+ data.leftEdgeId = road.leftEdgeId;
|
|
|
+ data.rightEdgeId = road.rightEdgeId;
|
|
|
+ data.way = road.way;
|
|
|
+ if (road.way == Constant.oneWay) {
|
|
|
+ data.singleRoadWidth = road.singleRoadWidth;
|
|
|
+ data.singleRoadDrivewayCount = road.singleRoadDrivewayCount;
|
|
|
+ data.singleLanes = JSON.parse(JSON.stringify(road.singleLanes));
|
|
|
+ } else if (road.way == Constant.twoWay) {
|
|
|
+ data.leftWidth = road.leftWidth;
|
|
|
+ data.rightWidth = road.rightWidth;
|
|
|
+ data.leftDrivewayCount = road.leftDrivewayCount;
|
|
|
+ data.rightDrivewayCount = road.rightDrivewayCount;
|
|
|
+ data.midDivide = JSON.parse(JSON.stringify(road.midDivide));
|
|
|
+ data.leftLanes = JSON.parse(JSON.stringify(road.leftLanes));
|
|
|
+ data.rightLanes = JSON.parse(JSON.stringify(road.rightLanes));
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ getDataForCrossPoint(crossPoint) {
|
|
|
+ const data = {};
|
|
|
+ data.id = crossPoint.vectorId;
|
|
|
+ data.type = crossPoint.geoType;
|
|
|
+ data.position = {};
|
|
|
+ mathUtil.clonePoint(data.position, crossPoint);
|
|
|
+ data.extremePoint = {};
|
|
|
+ mathUtil.clonePoint(data.extremePoint, crossPoint.extremePoint);
|
|
|
+
|
|
|
+ data.edgeInfo1 = JSON.parse(JSON.stringify(crossPoint.edgeInfo1));
|
|
|
+ data.edgeInfo2 = JSON.parse(JSON.stringify(crossPoint.edgeInfo2));
|
|
|
+ return data;
|
|
|
+ }
|
|
|
|
|
|
setPointInfo(pointInfo) {
|
|
|
let point = dataService.getPoint(pointInfo.vectorId);
|
|
|
mathUtil.clonePoint(point, pointInfo.position);
|
|
|
point.parent = JSON.parse(JSON.stringify(pointInfo.parent));
|
|
|
+ point.category = pointInfo.category;
|
|
|
return point;
|
|
|
}
|
|
|
|
|
@@ -194,6 +421,8 @@ export default class HistoryUtil {
|
|
|
let circle = dataService.getCircle(circleInfo.vectorId);
|
|
|
circle.center = circleInfo.center;
|
|
|
circle.radius = circleInfo.radius;
|
|
|
+ circle.color = circleInfo.color;
|
|
|
+ circle.points = circleInfo.points;
|
|
|
return circle;
|
|
|
}
|
|
|
|
|
@@ -204,12 +433,70 @@ export default class HistoryUtil {
|
|
|
text.value = textInfo.value;
|
|
|
}
|
|
|
|
|
|
+ setMagnifierInfo(magnifierInfo) {
|
|
|
+ let magnifier = dataService.getMagnifier(magnifierInfo.vectorId);
|
|
|
+ magnifier.vectorId = magnifierInfo.vectorId;
|
|
|
+ magnifier.position = JSON.parse(JSON.stringify(magnifierInfo.position));
|
|
|
+ magnifier.popPosition = JSON.parse(
|
|
|
+ JSON.stringify(magnifierInfo.popPosition)
|
|
|
+ );
|
|
|
+ magnifier.photoUrl = magnifierInfo.photoUrl;
|
|
|
+ }
|
|
|
+
|
|
|
setSVGInfo(svgInfo) {
|
|
|
let svg = dataService.getSVG(svgInfo.vectorId);
|
|
|
svg.vectorId = svgInfo.vectorId;
|
|
|
svg.center = JSON.parse(JSON.stringify(svgInfo.center));
|
|
|
svg.name = svgInfo.name;
|
|
|
}
|
|
|
+
|
|
|
+ setRoadPointInfo(roadPointInfo) {
|
|
|
+ let roadPoint = dataService.getRoadPoint(roadPointInfo.vectorId);
|
|
|
+ roadPoint.vectorId = roadPointInfo.vectorId;
|
|
|
+ mathUtil.clonePoint(roadPoint, roadPointInfo.position);
|
|
|
+ roadPoint.parent = JSON.parse(JSON.stringify(roadPointInfo.parent));
|
|
|
+ }
|
|
|
+
|
|
|
+ setRoadEdgeInfo(roadEdgeInfo) {
|
|
|
+ let roadEdge = dataService.getRoadEdge(roadEdgeInfo.vectorId);
|
|
|
+ roadEdge.vectorId = roadEdgeInfo.vectorId;
|
|
|
+ mathUtil.clonePoint(roadEdge.start, roadEdgeInfo.start);
|
|
|
+ mathUtil.clonePoint(roadEdge.end, roadEdgeInfo.end);
|
|
|
+ roadEdge.name = roadEdgeInfo.name;
|
|
|
+ }
|
|
|
+
|
|
|
+ setRoadInfo(roadInfo) {
|
|
|
+ let road = dataService.getRoad(roadInfo.vectorId);
|
|
|
+ road.vectorId = roadInfo.vectorId;
|
|
|
+ road.startId = roadInfo.startId;
|
|
|
+ road.endId = roadInfo.endId;
|
|
|
+ road.leftEdgeId = roadInfo.leftEdgeId;
|
|
|
+ road.rightEdgeId = roadInfo.rightEdgeId;
|
|
|
+ road.way = roadInfo.way;
|
|
|
+ if (road.way == Constant.oneWay) {
|
|
|
+ road.singleRoadWidth = roadInfo.singleRoadWidth;
|
|
|
+ road.singleRoadDrivewayCount = roadInfo.singleRoadDrivewayCount;
|
|
|
+ road.singleLanes = JSON.parse(JSON.stringify(roadInfo.singleLanes));
|
|
|
+ } else if (road.way == Constant.twoWay) {
|
|
|
+ road.leftWidth = roadInfo.leftWidth;
|
|
|
+ road.rightWidth = roadInfo.rightWidth;
|
|
|
+ road.leftDrivewayCount = roadInfo.leftDrivewayCount;
|
|
|
+ road.rightDrivewayCount = roadInfo.rightDrivewayCount;
|
|
|
+ road.midDivide = JSON.parse(JSON.stringify(roadInfo.midDivide));
|
|
|
+ road.leftLanes = JSON.parse(JSON.stringify(roadInfo.leftLanes));
|
|
|
+ road.rightLanes = JSON.parse(JSON.stringify(roadInfo.rightLanes));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ setCrossPointInfo(crossPointInfo) {
|
|
|
+ let crossPoint = dataService.getCrossPoint2(crossPointInfo.vectorId);
|
|
|
+ crossPoint.vectorId = crossPointInfo.vectorId;
|
|
|
+ mathUtil.clonePoint(crossPoint, crossPointInfo.position);
|
|
|
+ mathUtil.clonePoint(crossPoint.extremePoint, crossPointInfo.extremePoint);
|
|
|
+ crossPoint.edgeInfo1 = JSON.parse(JSON.stringify(crossPointInfo.edgeInfo1));
|
|
|
+ crossPoint.edgeInfo2 = JSON.parse(JSON.stringify(crossPointInfo.edgeInfo2));
|
|
|
+ crossPoint.curves = JSON.parse(JSON.stringify(crossPointInfo.curves));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const historyUtil = new HistoryUtil();
|