Browse Source

Merge branch 'master' of http://192.168.0.115:3000/bill/traffic-laser

bill 2 years ago
parent
commit
8f5e0260b9

+ 14 - 13
src/graphic/Controls/LocationModeControl.js

@@ -6,6 +6,7 @@ import { dataService } from "../Service/DataService";
 import { lineService } from "../Service/LineService";
 import { pointService } from "../Service/PointService";
 import VectorCategory from "../enum/VectorCategory";
+import Msg from "../enum/Msg";
 import Constant from "../Constant";
 import { uiService } from "../Service/UIService";
 
@@ -14,8 +15,9 @@ export default class LocationModeControl {
 
   //设置直角定位法
   setAngle() {
-    let selectBasePoint = this.beforeSetLocation();
-    if (selectBasePoint) {
+    const code = this.beforeSetLocation();
+    if (code == Msg.OK) {
+      let selectBasePoint = dataService.getPoint(Settings.selectBasePointId);
       this.deleteOldLines();
       let points = dataService.getPoints();
       for (let key in points) {
@@ -27,10 +29,8 @@ export default class LocationModeControl {
           );
         }
       }
-      return true;
-    } else {
-      return false;
     }
+    return code;
   }
 
   //对一个点进行直角定位法
@@ -102,6 +102,8 @@ export default class LocationModeControl {
     }
     if (basePointCount == 1) {
       uiService.setSelectBasePointId(selectBasePointId);
+    } else if (basePointCount > 1 && Settings.selectBasePointId == null) {
+      return Msg.UnSelectBasePoint;
     }
 
     if (
@@ -109,16 +111,15 @@ export default class LocationModeControl {
       fixPointCount == 0 ||
       Settings.baseLineId == null
     ) {
-      return null;
-    } else {
-      if (Settings.selectBasePointId) {
-        let point = dataService.getPoint(Settings.selectBasePointId);
-        if (point.getCategory() == VectorCategory.Point.BasePoint) {
-          return point;
-        }
+      if (basePointCount == 0) {
+        return Msg.UnBasePoint;
+      } else if (fixPointCount == 0) {
+        return Msg.UnFixPoint;
+      } else if (Settings.baseLineId == null) {
+        return Msg.UnBaseLine;
       }
-      return null;
     }
+    return Msg.OK;
   }
 
   /******************************************************************************************************************************************************/

+ 7 - 5
src/graphic/Controls/UIControl.js

@@ -34,6 +34,7 @@ import { locationModeControl } from "./LocationModeControl.js";
 import { curveRoadPointService } from "../Service/CurveRoadPointService.js";
 import { roadService } from "../Service/RoadService.js";
 import { curveRoadService } from "../Service/CurveRoadService.js";
+import Msg from "../enum/Msg.js";
 
 export default class UIControl {
   constructor(layer, newsletter, graphicStateUI) {
@@ -130,12 +131,13 @@ export default class UIControl {
           stateService.setEventName(LayerEvents.AddRoadStructure);
         } else if (selectUI == Constant.angleLocationMode) {
           uiService.setSelectLocationMode(Constant.angleLocationMode);
-          let flag = locationModeControl.setAngle();
-          if (!flag) {
-            this.prompt({ msg: "请先选择基准点", time: 1000 });
+          let msg = locationModeControl.setAngle();
+          if (msg != Msg.OK) {
+            this.prompt({ msg: msg, time: 1000 });
+          } else {
+            this.layer.history.save();
+            this.layer.renderer.autoRedraw();
           }
-          this.layer.history.save();
-          this.layer.renderer.autoRedraw();
         }
       }
     }

+ 3 - 2
src/graphic/enum/ErrMsg.js

@@ -1,8 +1,9 @@
-const ErrMsg = {
+const Msg = {
+  OK: "成功",
   UnBaseLine: "请先创建基准线",
   UnBasePoint: "请先创建基准点",
   UnSelectBasePoint: "请先选择基准点",
   UnFixPoint: "请先创建固定点",
 };
 
-export default ErrMsg;
+export default Msg;