管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2024-09-27 b637dca4802288affff11d528bfb0a6328a8ce79
TEWin/Resources/SpaceStatistics/SpaceStatistics.html
@@ -24,6 +24,79 @@
    var gAsync = true;
    var gDebug = false;
    var groupName = "空间统计";
    //var layerName = "JMD_1002";
    var rs = {
      count: 0, // 要素总个数
      lineLen: 0, // 线对象长度
      polyArea: 0, // 多边形面积
      volume: 0, // 三维体体积
      minHeight: 0, // 三维体最低高度
      maxHeight: 0, // 三维体最高高度
      data: [],
      reset: function () {
        //SGWorld.ProjectTree.EnableRedraw(0);
        var layers = getFeatureLayers();
        for (var i in layers) {
          try {
            SGWorld.ProjectTree.GetObject(layers[i]).Refresh();
          } catch (e) {
            console.log(e);
          }
        }
        //SGWorld.ProjectTree.EnableRedraw(1);
        this.count = 0;
        this.lineLen = 0;
        this.polyArea = 0;
        this.volume = 0;
        this.minHeight = 0;
        this.maxHeight = 0;
        this.data = [];
        return this;
      },
      format: function () {
        this.lineLen = parseFloat(this.lineLen.toFixed(2));
        this.polyArea = parseFloat(this.polyArea.toFixed(2));
        this.volume = parseFloat(this.volume.toFixed(2));
        this.minHeight = parseFloat(this.minHeight.toFixed(2));
        this.maxHeight = parseFloat(this.maxHeight.toFixed(2));
        return this;
      },
      setVal: function () {
        $("#totalNum").html("" + this.count);
        $("#lineLen").html("" + this.lineLen);
        $("#polyArea").html("" + this.polyArea);
        $("#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></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].area + "</td><td>" + this.data[i].height + "</td><td>" + this.data[i].vol + "</td></tr>";
        }
        html += "</table>";
        return html;
      }
    };
    $(function () {
      init();
@@ -45,49 +118,30 @@
        var gid = SGWorld.ProjectTree.FindItem(groupName);
        if (gid) SGWorld.ProjectTree.DeleteItem(gid);
      }
      catch (e) {
        console.log(e);
      }
      catch (e) { }
    }
    function getFeatureLayers() {
      var layers = [], index = 0;
      var layers = [];
      BuildObjectsList(SGWorld.ProjectTree.RootID, layers, 36);
      return layers;
    }
    function changeLayer(e) {
      var id = $(e).val();
      if (id) SGWorld.ProjectTree.SelectItem(id);
    }
    var buffer = 0;
    function changeBuffer(e) {
      var val = $(e).val();
      if (val == buffer || isNaN(val)) return;
      buffer = parseFloat(val);
      SGWorld.Command.Execute(1096, buffer);
    }
    function changeSR(e) {
      var val = parseInt($(e).val());
      SGWorld.Command.Execute(1097, val);
    }
    function openPropTab(e) {
      SGWorld.Command.Execute(1086, null);
    function clear(e) {
      rs.reset();
      rs.setVal();
      delGroup();
    }
    function startQuery(e) {
      delGroup();
      this.clear();
      if (drawing.drawingEditMode != -1) {
        drawing.abort();
        return;
      }
      SGWorld.Window.ShowMessageBarText("按 Esc 键退出");
      drawing.drawPolygon({
        style: {
          lineColor: "#ff0000",
@@ -103,9 +157,50 @@
    }
    function DrawPoly(geometry, type, altitudeType) {
      //SGWorld.Window.ShowMessageBarText("按 Esc 键退出");
      SGWorld.ProjectTree.EnableRedraw(0);
      alert(null==geometry);
      var layers = getFeatureLayers();
      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;
          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;
            }
          }
          if (layer.GeometryType == 2) { // LGT_POLYGON
            var hField = $.trim($("#hField").val()), fName = layer.TreeItem.Name;
            for (var j = 0; j < fs.Count; j++) {
              var f = fs.Item(j);
              rs.polyArea += f.Geometry.Area;
              try {
                var height = parseFloat(f.FeatureAttributes.GetFeatureAttribute(hField).Value);
                rs.volume += f.Geometry.Area * height;
                if (rs.maxHeight < height) rs.maxHeight = height;
                if (!rs.minHeight || rs.minHeight > height) rs.minHeight = height;
                rs.data.push({ "name": fName, "area": f.Geometry.Area.toFixed(2), "height": height.toFixed(2), "vol": (f.Geometry.Area * height).toFixed(2) });
              } catch (ex) {
                console.log(ex);
              }
            }
          }
          for (var j = 0; j < fs.Count; j++) {
            fs.Item(j).Tint.abgrColor = 0xff800080;
          }
        } catch (e) {
          console.log(e);
          //layers.splice(i, 1);
        }
      }
      rs.format();
      rs.setVal();
    }
    function ResetAsync(FirstTime, FromMouseInputMode) {
@@ -161,45 +256,47 @@
            <td class="s8b">
              <label for="Mode" class="i18n">线对象长度</label>
            </td>
            <td>&nbsp;<span id="lineLen">0</span> 千米
            <td>&nbsp;<span id="lineLen">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="polyArea">0</span> 平方千米
            <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;<select id="SpatialRelationship" onchange="changeSR(this);" style="width: 100pt;">
              <option class="i18n" value="1" selected="selected">相交</option>
              <option class="i18n" value="2">包含</option>
            </select>
            <td>&nbsp;<span id="volume">0</span> 立方米
            </td>
          </tr>
          <tr>
            <td class="s8b">
              <label for="Mode" class="i18n">查询类型</label>
              <label for="Mode" class="i18n">三维体高度</label>
            </td>
            <td>&nbsp;<select id="SelectType" style="width: 100pt;">
              <option value="1074">点查</option>
              <option value="1072">线查</option>
              <option value="1071" selected="selected">面查</option>
              <option value="1156">选择对象</option>
            </select>
            <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="openPropTab(this);" style="cursor: pointer;">
          <button id="clipboardButton" class="MenuButton" onclick="clear(this);" style="cursor: pointer;">
            <img src="img/delete.png" /><br />
            <span class="i18n">清 除</span></button>
          <button id="DrawPlaneBtn" class="MenuButton MenuButtonLast" onclick="startQuery(this);" style="cursor: pointer;">