|
@@ -11,6 +11,7 @@ import { coordinate } from "./Coordinate";
|
|
|
import { draw } from "./Renderer/Draw.js";
|
|
|
import { edgeService } from "./Service/EdgeService";
|
|
|
import VectorCategory from "./enum/VectorCategory";
|
|
|
+import LayerEvents from "./enum/LayerEvents";
|
|
|
|
|
|
export default class ListenLayer {
|
|
|
constructor() {
|
|
@@ -78,6 +79,10 @@ export default class ListenLayer {
|
|
|
position,
|
|
|
exceptVectorIds.exceptCircleId
|
|
|
);
|
|
|
+ selectInfo.ellipticInfo = this.isSelectElliptic(
|
|
|
+ position,
|
|
|
+ exceptVectorIds.exceptEllipticId
|
|
|
+ );
|
|
|
//交叉口拐弯处的控制点
|
|
|
selectInfo.crossPointInfo = this.isSelectCrossCrossPoint(
|
|
|
position,
|
|
@@ -291,6 +296,11 @@ export default class ListenLayer {
|
|
|
if (exceptLineId == lineId) {
|
|
|
continue;
|
|
|
}
|
|
|
+ if (stateService.getEventName() == LayerEvents.MovePoint) {
|
|
|
+ console.log("选中的isSelectLine:" + exceptLineId);
|
|
|
+ debugger;
|
|
|
+ }
|
|
|
+
|
|
|
const line = dataService.getLine(lineId);
|
|
|
if (
|
|
|
line.getCategory() == VectorCategory.Line.PositionLine ||
|
|
@@ -373,121 +383,68 @@ export default class ListenLayer {
|
|
|
return circleInfo;
|
|
|
}
|
|
|
|
|
|
- // isSelectCurveLine(position, exceptCurveLineId) {
|
|
|
- // let curveLineInfo = {
|
|
|
- // curveLineId: null,
|
|
|
- // type: null,
|
|
|
- // distance: null,
|
|
|
- // };
|
|
|
- // let seqInfo = {};
|
|
|
- // const curveLines = dataService.getCurveLines();
|
|
|
+ isSelectElliptic(position, exceptEllipticId) {
|
|
|
+ let ellipticInfo = {
|
|
|
+ ellipticId: null,
|
|
|
+ type: null,
|
|
|
+ distance: null,
|
|
|
+ };
|
|
|
+ const elliptics = dataService.getElliptics();
|
|
|
+ let distance;
|
|
|
+ for (const ellipticId in elliptics) {
|
|
|
+ if (ellipticId == exceptEllipticId) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const elliptic = dataService.getElliptic(ellipticId);
|
|
|
+ for (let i = 0; i < elliptic.points.length; ++i) {
|
|
|
+ distance = this.getDistance(position, elliptic.points[i]);
|
|
|
+ if (distance < Constant.minAdsorbPix) {
|
|
|
+ ellipticInfo = {
|
|
|
+ ellipticId: ellipticId,
|
|
|
+ type: VectorType.Elliptic,
|
|
|
+ distance: distance,
|
|
|
+ x: elliptic.points[i].x,
|
|
|
+ y: elliptic.points[i].y,
|
|
|
+ index: i,
|
|
|
+ };
|
|
|
+ return ellipticInfo;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // for (const curveLineId in curveLines) {
|
|
|
- // if (curveLineId == exceptCurveLineId) {
|
|
|
- // continue;
|
|
|
- // }
|
|
|
- // const curveLine = dataService.getCurveLine(curveLineId);
|
|
|
- // let joinInfo = this.distanceForBezier(
|
|
|
- // position,
|
|
|
- // curveRoad.curves,
|
|
|
- // Constant.minAdsorbPix / 2
|
|
|
- // );
|
|
|
+ const distanceX = mathUtil.getDistance(
|
|
|
+ elliptic.points[2],
|
|
|
+ elliptic.points[3]
|
|
|
+ );
|
|
|
+ const distanceY = mathUtil.getDistance(
|
|
|
+ elliptic.points[0],
|
|
|
+ elliptic.points[1]
|
|
|
+ );
|
|
|
+ const flag = mathUtil.isPointInElliptic(
|
|
|
+ position,
|
|
|
+ elliptic.center,
|
|
|
+ distanceX,
|
|
|
+ distanceY
|
|
|
+ );
|
|
|
+ distance = this.getDistance(position, elliptic.center);
|
|
|
+ if (flag) {
|
|
|
+ if (
|
|
|
+ ellipticInfo.ellipticId == null ||
|
|
|
+ distance < ellipticInfo.distance
|
|
|
+ ) {
|
|
|
+ ellipticInfo = {
|
|
|
+ ellipticId: ellipticId,
|
|
|
+ type: VectorType.Elliptic,
|
|
|
+ distance: distance,
|
|
|
+ x: elliptic.center.x,
|
|
|
+ y: elliptic.center.y,
|
|
|
+ index: -1,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // if (
|
|
|
- // mathUtil.isClockwise([curveRoad.points[0], joinInfo.position, position])
|
|
|
- // ) {
|
|
|
- // //选中了路
|
|
|
- // if (joinInfo.distance < curveRoad.leftWidth - Constant.minAdsorbPix) {
|
|
|
- // curveRoadInfo = {
|
|
|
- // curveRoadId: curveRoadId,
|
|
|
- // type: VectorType.CurveRoad,
|
|
|
- // distance: joinInfo.distance,
|
|
|
- // x: joinInfo.position.x,
|
|
|
- // y: joinInfo.position.y,
|
|
|
- // };
|
|
|
- // }
|
|
|
- // //选中了edge
|
|
|
- // else if (
|
|
|
- // joinInfo.distance <
|
|
|
- // curveRoad.leftWidth + Constant.minAdsorbPix
|
|
|
- // ) {
|
|
|
- // const leftCurveEdge = dataService.getCurveRoadEdge(
|
|
|
- // curveRoad.leftEdgeId
|
|
|
- // );
|
|
|
- // joinInfo = this.distanceForBezier(
|
|
|
- // position,
|
|
|
- // leftCurveEdge.curves,
|
|
|
- // curveRoad.leftWidth
|
|
|
- // );
|
|
|
- // const index = mathUtil.getIndexForCurvesPoints(
|
|
|
- // joinInfo.position,
|
|
|
- // curveRoad.points
|
|
|
- // );
|
|
|
- // curveEdgeInfo = {
|
|
|
- // curveEdgeId: curveRoad.leftEdgeId,
|
|
|
- // type: VectorType.CurveRoadEdge,
|
|
|
- // distance: joinInfo.distance,
|
|
|
- // selectIndex: index,
|
|
|
- // x: joinInfo.position.x,
|
|
|
- // y: joinInfo.position.y,
|
|
|
- // };
|
|
|
- // }
|
|
|
- // } else if (
|
|
|
- // !mathUtil.isClockwise([
|
|
|
- // curveRoad.points[0],
|
|
|
- // joinInfo.position,
|
|
|
- // position,
|
|
|
- // ])
|
|
|
- // ) {
|
|
|
- // //选中了路
|
|
|
- // if (joinInfo.distance < curveRoad.rightWidth - Constant.minAdsorbPix) {
|
|
|
- // curveRoadInfo = {
|
|
|
- // curveRoadId: curveRoadId,
|
|
|
- // type: VectorType.CurveRoad,
|
|
|
- // distance: joinInfo.distance,
|
|
|
- // x: joinInfo.position.x,
|
|
|
- // y: joinInfo.position.y,
|
|
|
- // };
|
|
|
- // }
|
|
|
- // //选中了edge
|
|
|
- // else if (
|
|
|
- // joinInfo.distance <
|
|
|
- // curveRoad.rightWidth + Constant.minAdsorbPix
|
|
|
- // ) {
|
|
|
- // const rightCurveEdge = dataService.getCurveRoadEdge(
|
|
|
- // curveRoad.rightEdgeId
|
|
|
- // );
|
|
|
- // joinInfo = this.distanceForBezier(
|
|
|
- // position,
|
|
|
- // rightCurveEdge.curves,
|
|
|
- // curveRoad.rightWidth
|
|
|
- // );
|
|
|
- // const index = mathUtil.getIndexForCurvesPoints(
|
|
|
- // joinInfo.position,
|
|
|
- // curveRoad.points
|
|
|
- // );
|
|
|
- // curveEdgeInfo = {
|
|
|
- // curveEdgeId: curveRoad.rightEdgeId,
|
|
|
- // type: VectorType.CurveRoadEdge,
|
|
|
- // distance: joinInfo.distance,
|
|
|
- // selectIndex: index,
|
|
|
- // x: joinInfo.position.x,
|
|
|
- // y: joinInfo.position.y,
|
|
|
- // };
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (curveRoadInfo.curveRoadId) {
|
|
|
- // return curveRoadInfo;
|
|
|
- // } else if (curveEdgeInfo.curveEdgeId) {
|
|
|
- // return curveEdgeInfo;
|
|
|
- // } else {
|
|
|
- // return {
|
|
|
- // curveRoadId: null,
|
|
|
- // curveEdgeId: null,
|
|
|
- // };
|
|
|
- // }
|
|
|
- // }
|
|
|
+ return ellipticInfo;
|
|
|
+ }
|
|
|
|
|
|
isSelectRoadPoint(position, exceptRoadPointId) {
|
|
|
let roadPointInfo = {
|
|
@@ -1138,6 +1095,12 @@ export default class ListenLayer {
|
|
|
this.modifyPoint.index = info.circleInfo.index;
|
|
|
this.modifyPoint.x = info.circleInfo.x;
|
|
|
this.modifyPoint.y = info.circleInfo.y;
|
|
|
+ } else if (info && info.ellipticInfo.ellipticId) {
|
|
|
+ this.modifyPoint = {};
|
|
|
+ this.modifyPoint.linkedEllipticId = info.ellipticInfo.ellipticId;
|
|
|
+ this.modifyPoint.index = info.ellipticInfo.index;
|
|
|
+ this.modifyPoint.x = info.ellipticInfo.x;
|
|
|
+ this.modifyPoint.y = info.ellipticInfo.y;
|
|
|
} else if (info && info.roadPointInfo.linkedRoadPointIdX) {
|
|
|
this.modifyPoint = {};
|
|
|
this.modifyPoint.linkedRoadPointIdX =
|
|
@@ -1298,6 +1261,12 @@ export default class ListenLayer {
|
|
|
VectorType.Circle,
|
|
|
this.modifyPoint.index
|
|
|
);
|
|
|
+ } else if (this.modifyPoint.linkedEllipticId) {
|
|
|
+ stateService.setSelectItem(
|
|
|
+ this.modifyPoint.linkedEllipticId,
|
|
|
+ VectorType.Elliptic,
|
|
|
+ this.modifyPoint.index
|
|
|
+ );
|
|
|
} else {
|
|
|
stateService.clearSelectItem();
|
|
|
}
|