管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2024-09-27 2b8aed5af4cd96a6aafc6fdb7fd0b7e9352ed498
TEWin/Resources/SpaceStatistics/SpaceStatistics.html
@@ -24,7 +24,7 @@
    var gAsync = true;
    var gDebug = false;
    var groupName = "空间统计";
    var layerName = "JMD_1002";
    //var layerName = "JMD_1002";
    var rs = {
      count: 0, // 要素总个数
@@ -39,12 +39,18 @@
      maxHeight: 0, // 三维体最高高度
      data: [],
      reset: function () {
        //SGWorld.ProjectTree.EnableRedraw(0);
        var layers = getFeatureLayers();
        var hField = $.trim($("#hField").val());
        for (var i in layers) {
          try{
          try {
            SGWorld.ProjectTree.GetObject(layers[i]).Refresh();
            //var layer = SGWorld.ProjectTree.GetObject(layers[i]);
            //var flag = layer.DataSourceInfo.Attributes.IsAttributeExist(hField);
            //if (layer.GeometryType == 2 && flag) layer.Refresh();
          } catch (e) {
            console.log(e);
          }
@@ -57,6 +63,7 @@
        this.volume = 0;
        this.minHeight = 0;
        this.maxHeight = 0;
        this.data = [];
        return this;
      },
@@ -78,6 +85,20 @@
        $("#volume").html("" + this.volume);
        $("#minHeight").html("" + this.minHeight);
        $("#maxHeight").html("" + this.maxHeight);
        $("#cc").html(this.getHtmlByData());
      },
      getHtmlByData: function () {
        if (!this.data || !this.data.length) return "";
        var html = "<table class='PropertiesSheet' cellspacing='0' cellpadding='2' style='max-height: 256px; overflow: auto'>";
        html += "<tr><td>序号</td><td>图层名</td><td>线长</td><td>面积</td><td>高度</td><td>体积</td></tr>";
        for (var i = 0, c = this.data.length; i < c; i++) {
          html += "<tr><td>" + (i + 1) + "</td><td>" + this.data[i].name + "</td><td>" + this.data[i].len + "</td><td>" + this.data[i].area + "</td><td>" + this.data[i].height + "</td><td>" + this.data[i].vol + "</td></tr>";
        }
        html += "</table>";
        return html;
      }
    };
@@ -141,33 +162,38 @@
    function DrawPoly(geometry, type, altitudeType) {
      var layers = getFeatureLayers();
      var hField = $.trim($("#hField").val());
      for (var i in layers) {
        try {
          var layer = SGWorld.ProjectTree.GetObject(layers[i]);
          var fs = layer.ExecuteSpatialQuery(geometry, 1); // 1-IT_INTERSECT, 2-IT_WITHIN
          if (fs.Count == 0) continue;
          var fName = layer.TreeItem.Name;
          rs.count += fs.Count;
          if (layer.GeometryType == 1) { // LGT_POLYLINE
            for (var j = 0; j < fs.Count; j++) {
              var f = fs.Item(j);
              rs.lineLen += f.Geometry.Length;
              rs.data.push({ "name": fName, "len": f.Geometry.Length.toFixed(2), "area": "", "height": "", "vol": "" });
            }
          }
          if (layer.GeometryType == 2) { // LGT_POLYGON
            var flag = layerName == layer.TreeItem.Name;
            var flag = layer.DataSourceInfo.Attributes.IsAttributeExist(hField);
            for (var j = 0; j < fs.Count; j++) {
              var f = fs.Item(j);
              rs.polyArea += f.Geometry.Area;
              if (flag) {
                var maxHeight = f.FeatureAttributes.GetFeatureAttribute("MaxHeight").Value;
                var minHeight = f.FeatureAttributes.GetFeatureAttribute("MinHeight").Value;
                var height = maxHeight - minHeight;
                rs.volume += f.Geometry.Area * height;
                var height = parseFloat(f.FeatureAttributes.GetFeatureAttribute(hField).Value);
                var volume = f.Geometry.Area * height;
                rs.volume += volume;
                if (rs.maxHeight < height) rs.maxHeight = height;
                if (!rs.minHeight || rs.minHeight > height) rs.minHeight = height;
                rs.data.push({ "name": fName, "len": "", "area": f.Geometry.Area.toFixed(2), "height": height.toFixed(2), "vol": volume.toFixed(2) });
              } else {
                rs.data.push({ "name": fName, "len": "", "area": f.Geometry.Area.toFixed(2), "height": "", "vol": "" });
              }
            }
          }
@@ -175,8 +201,7 @@
            fs.Item(j).Tint.abgrColor = 0xff800080;
          }
        } catch (e) {
          console.log(e);
          //layers.splice(i, 1);
          console.log(e); // layers.splice(i, 1);
        }
      }
@@ -242,14 +267,14 @@
          </tr>
          <tr>
            <td class="s8b">
              <label for="Mode" class="i18n">多边形面积</label>
              <label for="Mode" class="i18n">多边形总面积</label>
            </td>
            <td>&nbsp;<span id="polyArea">0</span> 平方米
            </td>
          </tr>
          <tr>
            <td class="s8b">
              <label for="Mode" class="i18n">三维体体积</label>
              <label for="Mode" class="i18n">空间体积</label>
            </td>
            <td>&nbsp;<span id="volume">0</span> 立方米
            </td>
@@ -261,10 +286,20 @@
            <td>&nbsp;最低 <span id="minHeight">0</span> 米,最高 <span id="maxHeight">0</span> 米
            </td>
          </tr>
          <tr>
            <td class="s8b">
              <label for="Mode" class="i18n">高度字段</label>
            </td>
            <td>&nbsp;<input id="hField" type="text" value="GD" />
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr class="s8">
      <td id="cc"></td>
    </tr>
    <tr class="s8">
      <td align="center" class="ToolButtonsArea">
        <div id="SurfaceDiv">
          <button id="clipboardButton" class="MenuButton" onclick="clear(this);" style="cursor: pointer;">