|
@@ -1,3 +1,6 @@
|
|
|
+import Constant from "../Constant.js";
|
|
|
+import { dataService } from "../Service/DataService.js";
|
|
|
+import { mathUtil } from "../Util/MathUtil.js";
|
|
|
import VectorType from "../enum/VectorType.js";
|
|
|
import Geometry from "./Geometry";
|
|
|
|
|
@@ -25,6 +28,8 @@ export default class ControlPoint extends Geometry {
|
|
|
dir: null,
|
|
|
};
|
|
|
|
|
|
+ this.extremePoint = null; //极值
|
|
|
+ this.curves = [];
|
|
|
this.geoType = VectorType.ControlPoint;
|
|
|
this.setId(vectorId);
|
|
|
|
|
@@ -36,6 +41,61 @@ export default class ControlPoint extends Geometry {
|
|
|
this.y = position.y;
|
|
|
}
|
|
|
|
|
|
+ setExtremePoint() {
|
|
|
+ let points = [];
|
|
|
+ let edge1 = dataService.getRoadEdge(this.edgeInfo1.id);
|
|
|
+ if (this.edgeInfo1.dir == "start") {
|
|
|
+ points[0] = edge1.start;
|
|
|
+ } else if (this.edgeInfo1.dir == "end") {
|
|
|
+ points[0] = edge1.end;
|
|
|
+ }
|
|
|
+ points[1] = {
|
|
|
+ x: this.x,
|
|
|
+ y: this.y,
|
|
|
+ };
|
|
|
+ let edge2 = dataService.getRoadEdge(this.edgeInfo2.id);
|
|
|
+ if (this.edgeInfo2.dir == "start") {
|
|
|
+ points[2] = edge2.start;
|
|
|
+ } else if (this.edgeInfo2.dir == "end") {
|
|
|
+ points[2] = edge2.end;
|
|
|
+ }
|
|
|
+ let curves = mathUtil.getCurvesByPoints(points);
|
|
|
+ let joinInfo = mathUtil.getHitInfoForCurves(
|
|
|
+ points[1],
|
|
|
+ curves,
|
|
|
+ Constant.defaultRoadWidth
|
|
|
+ );
|
|
|
+ this.extremePoint = {};
|
|
|
+ mathUtil.clonePoint(this.extremePoint, joinInfo.position);
|
|
|
+ this.curves = mathUtil.getCurvesByPoints([
|
|
|
+ points[0],
|
|
|
+ this.extremePoint,
|
|
|
+ points[2],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ setCurves() {
|
|
|
+ let points = [];
|
|
|
+ let edge1 = dataService.getRoadEdge(this.edgeInfo1.id);
|
|
|
+ if (this.edgeInfo1.dir == "start") {
|
|
|
+ points[0] = edge1.start;
|
|
|
+ } else if (this.edgeInfo1.dir == "end") {
|
|
|
+ points[0] = edge1.end;
|
|
|
+ }
|
|
|
+ points[1] = {
|
|
|
+ x: this.x,
|
|
|
+ y: this.y,
|
|
|
+ };
|
|
|
+ let edge2 = dataService.getRoadEdge(this.edgeInfo2.id);
|
|
|
+ if (this.edgeInfo2.dir == "start") {
|
|
|
+ points[2] = edge2.start;
|
|
|
+ } else if (this.edgeInfo2.dir == "end") {
|
|
|
+ points[2] = edge2.end;
|
|
|
+ }
|
|
|
+ points[1] = this.extremePoint;
|
|
|
+ this.curves = mathUtil.getCurvesByPoints(points);
|
|
|
+ }
|
|
|
+
|
|
|
setEdgeInfo(edgeId1, dir1, edgeId2, dir2) {
|
|
|
this.edgeInfo1.id = edgeId1;
|
|
|
this.edgeInfo1.dir = dir1;
|