瀏覽代碼

fix ZDM里程优化

zhanghaijun 3 年之前
父節點
當前提交
11f05df3f4
共有 4 個文件被更改,包括 54 次插入 和 13 次删除
  1. 42 2
      scripts/Common/DrawZdmAll.js
  2. 6 0
      scripts/Common/DrawingUtils.js
  3. 2 3
      scripts/Common/FileCTR.js
  4. 4 8
      scripts/Common/FileZDM.js

+ 42 - 2
scripts/Common/DrawZdmAll.js

@@ -45,11 +45,11 @@ DrawZdmAll.prototype.applyPainting = function (layer, dmxFile, zdmFile, ctrFile,
   var text_width = 260;
   addPolylinetoView([[startPoint[0] - text_width, startPoint[1]], endPoint], false, false, 0, this.frameColor);
   var array = new Array();
-  array.push({ name: "R", "space": 60, text: "竖曲线半径 (m)" });
+  array.push({ name: "R", "space": 100, text: "竖曲线半径 (m)" });
   array.push({ name: "SJGC", "space": 100, text: "设计高程 (m)" });
   array.push({ name: "DMGC", "space": 100, text: "地面高程 (m)" });
   array.push({ name: "PDPC", "space": 100, text: "坡度 (%) 坡长 (m)" });
-  array.push({ name: "BLZH", "space": 120, text: "百里桩号 (km)" });
+  array.push({ name: "BLZH", "space": 100, text: "百里桩号 (km)" });
   for (var i = 0; i < array.length; i++) {
     var item = array[i];
     var space = (item.space || 100);
@@ -102,6 +102,46 @@ DrawZdmAll.prototype.applyHeightMileage = function (arrayData, startPoint, space
   }
 }
 DrawZdmAll.prototype.applyMileage = function (arrayData, startPoint, space) {
+  // 记录里程
+  var mileage = 0.0;
+  // 最小间距
+  var space_min = 30;
+  var y = startPoint[1] - space;
+  for (var i = 0; i < arrayData.length; i++) {
+    var x = arrayData[i][0];
+    var mileage_current = x;
+    if (i == 0) {
+      // 显示起始桩号
+      addSimpleTextToView(formatStake(mileage_current), [x, y + 10], 15, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+      addPolylinetoView([[x, y], [x, y + 5]], false, false, 0, new RColor(255, 255, 0));
+      mileage = mileage_current;
+      continue;
+    }
+    if (mileage_current - mileage > space_min) {
+      // 绘画高程文本
+      addSimpleTextToView((round((mileage_current % 1000) * 1000) / 1000).toString(), [x, y + (space * 1 / 3) - 10], 15, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+    }
+    mileage = mileage_current;
+  }
+  // 绘制标准的百里标、千里表
+  var start = arrayData[0][0];
+  var end = arrayData[arrayData.length - 1][0];
+  // 下一个百里标的位置
+  var currentMiles = Math.ceil(start / 100) * 100;
+  // 循环打印百里和千里位置
+  while (currentMiles <= end) {
+    if (currentMiles % 1000 === 0) {
+      addSimpleTextToView("K" + Math.floor(currentMiles / 1000).toString(), [currentMiles, y + 10], 15, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+      addPolylinetoView([[currentMiles, y], [currentMiles, y + 5]], false, false, 0, new RColor(255, 255, 0));
+    } else if (currentMiles % 100 === 0) {
+      var text = currentMiles - (Math.floor(currentMiles / 1000) * 1000);
+      addSimpleTextToView(Math.floor(text / 100).toString(), [currentMiles, y + 10], 15, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+      addPolylinetoView([[currentMiles, y], [currentMiles, y + 5]], false, false, 0, new RColor(255, 255, 0));
+    }
+    currentMiles += 100;
+  }
+}
+DrawZdmAll.prototype.applyMileage_1010 = function (arrayData, startPoint, space) {
   var spaceDistance = 0;
   var bailiDistance = 0;
   var tenBailiDistance = 0;

+ 6 - 0
scripts/Common/DrawingUtils.js

@@ -117,3 +117,9 @@ function formatDateTime() {
   var seconds = String(now.getSeconds()).padStart(2, '0');
   return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
 }
+/** 格式化桩号 格式:K000+000.000 */
+function formatStake(middleX) {
+  var m = (round(middleX * 1000) / 1000);
+  var mk = Math.floor(m / 1000);
+  return "K" + mk.toString() + "+" + (round((m - mk * 1000) * 1000) / 1000).toString();
+}

+ 2 - 3
scripts/Common/FileCTR.js

@@ -1,5 +1,6 @@
 include("scripts/EAction.js");
 include("scripts/simple.js");
+include("scripts/Common/DrawingUtils.js");
 
 function FileCTR(file, ratio) {
   // 比例尺
@@ -135,9 +136,7 @@ FileCTR.prototype.applyBridge = function (zdmArrayData, dmxArrayData, PDColor) {
     addPolylinetoView([[middleZdm.x, middleZdm.y - 3], [middleDmx.x, middleDmx.y]], false, false, 0, PDColor);
     // 里程格式和ZDM里程格式一致
     // 里程单位是km,格式应该为K000+000.000
-    var milestone = (round(bridgeMiddleX * 1000) / 1000);
-    var milestoneK = round(milestone / 1000);
-    addSimpleTextToView("K" + milestoneK.toString() + "+" + (milestone - milestoneK).toString(), [middleZdm.x + 9, middleZdm.y + 6], 10, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+    addSimpleTextToView(formatStake(bridgeMiddleX * this.ratio), [middleZdm.x + 5, middleZdm.y + 2], 10, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
     addPolylinetoView([[middleZdm.x, middleZdm.y], [middleZdm.x, middleZdm.y + 50]], false, false, 0, PDColor);
   }
 };

+ 4 - 8
scripts/Common/FileZDM.js

@@ -88,9 +88,7 @@ FileZDM.prototype.applyOperation = function () {
       addCircleToView(this.newFZEntityData[i + 1][0], this.newFZEntityData[i + 1][1], 0.5, 0, FZXColor);
       addLineToView([this.newFZEntityData[i + 1][0], this.newFZEntityData[i + 1][1] + 1.5], [this.newFZEntityData[i + 1][0], this.newFZEntityData[i + 1][1] + 50], 0);
       // 里程单位是km,格式应该为K000+000.000
-      var milestone = (round(this.newFZEntityData[i + 1][0] * 1000 * this.ratio) / 1000);
-      var milestoneK = round(milestone / 1000);
-      addSimpleTextToView("K" + milestoneK.toString() + "+" + (milestone - milestoneK).toString(), [this.newFZEntityData[i + 1][0] - 9, this.newFZEntityData[i + 1][1] + 2.5], 7, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+      addSimpleTextToView(formatStake(this.newFZEntityData[i + 1][0] * this.ratio), [this.newFZEntityData[i + 1][0] - 9, this.newFZEntityData[i + 1][1] + 2.5], 7, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
       addSimpleTextToView(this.newFZEntityData[i + 1][1].toString(), [this.newFZEntityData[i + 1][0] + 2, this.newFZEntityData[i + 1][1] + 3], 7, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
       // EAction.handleUserMessage("start point end point:" + this.newFZEntityData[i + 1][0] + "," + (this.newFZEntityData[i + 1][1]+1)+";"+this.newFZEntityData[i + 1][0]+","+ (this.newFZEntityData[i + 1][1]+10));
     }
@@ -253,11 +251,9 @@ FileZDM.prototype.readTxt = function (file) {
 FileZDM.prototype.applyRadius = function (startPoint, space) {
   for (var i = 0; i < this.newFZEntityData.length; i += 3) {
     if (i + 2 < this.newFZEntityData.length && this.newFZEntityData[i + 2][2] == 3) {
-      // addLineToView([this.newFZEntityData[i + 2][0], this.newFZEntityData[i + 2][1] - 1.5], [this.newFZEntityData[i + 2][0], this.newFZEntityData[i + 2][1] + 1.5], 0);
-      // addLineToView([this.newFZEntityData[i + 2][0] - 0.5, this.newFZEntityData[i + 2][1] - 1.5], [this.newFZEntityData[i + 2][0], this.newFZEntityData[i + 2][1] - 1.5], 0);
-      // addLineToView([this.newFZEntityData[i + 2][0] - 0.5, this.newFZEntityData[i + 2][1] + 1.5], [this.newFZEntityData[i + 2][0], this.newFZEntityData[i + 2][1] + 1.5], 0);
-      addSimpleTextToView("R-" + this.allR[i % 3].toString(), [this.newFZEntityData[i][0], startPoint[1] - 20], 12, 0, "Standard", RS.VAlignTop, RS.HAlignLeft, true, false, 0);
-      addLineToView([this.newFZEntityData[i][0], startPoint[1] - 40], [this.newFZEntityData[i + 2][0], startPoint[1] - 40], 0);
+      var y = startPoint[1] - (space * 1 / 3);
+      addSimpleTextToView("R-" + this.allR[i % 3].toString(), [this.newFZEntityData[i][0], y], 12, 0, "Standard", RS.VAlignTop, RS.HAlignLeft, true, false, 0);
+      addLineToView([this.newFZEntityData[i][0], y - 16], [this.newFZEntityData[i + 2][0], y - 16], 0);
     }
   }
 }