jinx 1 vuosi sitten
vanhempi
commit
dc32a4b2b5
2 muutettua tiedostoa jossa 40 lisäystä ja 15 poistoa
  1. 40 14
      src/graphic/Geometry/CurveRoadEdge.js
  2. 0 1
      src/graphic/Geometry/RoadEdge.js

+ 40 - 14
src/graphic/Geometry/CurveRoadEdge.js

@@ -52,23 +52,49 @@ export default class CurveRoadEdge extends Geometry {
   }
 
   initCurveRoadSide() {
-    if (this.curveRoadSide.width) {
-      let curveRoad = dataService.getCurveRoad(this.parent);
-      this.curveRoadSide.points = [];
-      this.curveRoadSide.curves = [];
-      for (let i = 0; i < curveRoad.points.length; ++i) {
-        this.curveRoadSide.points[i] = mathUtil.getLineEndPointPos(
-          curveRoad.points[i],
-          this.points[i],
-          this.curveRoadSide.width
-        );
+    if (!this.curveRoadSide) {
+      this.curveRoadSide = {};
+      this.curveRoadSide["width"] = Constant.roadSideWidth;
+    }
+
+    let startPoint = this.start;
+    let curveRoad = dataService.getCurveRoad(this.parent);
+
+    let endPoint = this.end;
+
+    let curveRoadSidePoints = mathUtil.RectangleVertex(startPoint, endPoint, (this.curveRoadSide.width * 100 * window.devicePixelRatio) / 5);
+    for (let key in curveRoad) {
+      if (this.vectorId == curveRoad[key]) {
+        if (key == "rightEdgeId") {
+          this.curveRoadSide["start"] = curveRoadSidePoints.rightEdgeStart;
+          this.curveRoadSide["end"] = curveRoadSidePoints.rightEdgeEnd;
+        } else if (key == "leftEdgeId") {
+          this.curveRoadSide["start"] = curveRoadSidePoints.leftEdgeStart;
+          this.curveRoadSide["end"] = curveRoadSidePoints.leftEdgeEnd;
+        }
       }
-      this.curveRoadSide.curves = mathUtil.getCurvesByPoints(
-        this.curveRoadSide.points
-      );
     }
-  }
 
+    // if (this.curveRoadSide.width) {
+    //   let curveRoad = dataService.getCurveRoad(this.parent);
+    //   this.curveRoadSide.points = [];
+    //   this.curveRoadSide.curves = [];
+    //   for (let i = 0; i < curveRoad.points.length; ++i) {
+    //     this.curveRoadSide.points[i] = mathUtil.getLineEndPointPos(
+    //       curveRoad.points[i],
+    //       this.points[i],
+    //       this.curveRoadSide.width
+    //     );
+    //   }
+    //   this.curveRoadSide.curves = mathUtil.getCurvesByPoints(
+    //     this.curveRoadSide.points
+    //   );
+    // }
+  }
+  setRoadSideWidth(width) {
+    this.curveRoadSide.width = width;
+    this.initCurveRoadSide();
+  }
   removeCurveRoadSide() {
     this.curveRoadSide = null;
   }

+ 0 - 1
src/graphic/Geometry/RoadEdge.js

@@ -101,7 +101,6 @@ export default class RoadEdge extends Geometry {
     // this.roadSide['end'] = point2;
   }
   setRoadSideWidth(width) {
-    console.error(width);
     this.roadSide.width = width;
     this.initRoadSide();
   }