From 566e0d21293a5fe6423fd7a16541bce00eeb2e38 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 27 九月 2024 11:15:21 +0800 Subject: [PATCH] OK --- TEWin/Resources/SpaceStatistics/SpaceStatistics.html | 230 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 170 insertions(+), 60 deletions(-) diff --git a/TEWin/Resources/SpaceStatistics/SpaceStatistics.html b/TEWin/Resources/SpaceStatistics/SpaceStatistics.html index 0dfbac5..d99f6d0 100644 --- a/TEWin/Resources/SpaceStatistics/SpaceStatistics.html +++ b/TEWin/Resources/SpaceStatistics/SpaceStatistics.html @@ -24,8 +24,89 @@ var gAsync = true; var gDebug = false; var groupName = "绌洪棿缁熻"; + //var layerName = "JMD_1002"; - function getGroupId() { + 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(); + }); + + function init() { + window.ondragstart = function () { return false; } + } + + function getGroupId() { var gid = SGWorld.ProjectTree.FindItem(groupName); if (gid) return gid; @@ -37,50 +118,30 @@ var gid = SGWorld.ProjectTree.FindItem(groupName); if (gid) SGWorld.ProjectTree.DeleteItem(gid); } - catch (e) { - console.log(e); - } + catch (e) { } } - $(function () { - init(); - }); + function getFeatureLayers() { + var layers = []; + BuildObjectsList(SGWorld.ProjectTree.RootID, layers, 36); - function init() { - window.ondragstart = function () { return false; } + 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", @@ -96,8 +157,50 @@ } function DrawPoly(geometry, type, altitudeType) { - //SGWorld.Window.ShowMessageBarText("鎸� Esc 閿��鍑�"); - SGWorld.ProjectTree.EnableRedraw(0); + 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) { @@ -121,17 +224,17 @@ } </script> </head> -<body> - <table style="border: 0; padding: 0; border-spacing: 0; border-spacing: 2px; width: 100%;"> +<body class="hideUntillTranslated"> + <table style="width: 100%; border: 0;" cellspacing="0" cellpadding="2"> <tr> - <td class="ToolTopArea" width="100%" valign="middle"> + <td class="ToolTopArea" id="TopAreaTD" width="100%" valign="middle"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="55px"> <img style="margin-left: 5px;" src="img/ToolIcon.png" alt="" /></td> <td id="TitleTD" align="center" class="s12w i18n">绌洪棿缁熻</td> <td align="right" id="CloseHelpTd"> - <img style="margin-right: 5px;" alt="" src="../CommonImg/help.png" border="0" class="i18n" alt="help" title="甯姪" onclick="DisplayHelpPopup6(SGLang.i18nFile('help.html'),SGLang.i18n('help'))" style="cursor: pointer;"/></td> + <img style="margin-right: 5px; cursor: pointer;" alt="" src="../CommonImg/help.png" border="0" class="i18n" alt="help" title="甯姪" onclick="DisplayHelpPopup6(SGLang.i18nFile('help.html'),SGLang.i18n('help'))" /></td> </tr> </table> </td> @@ -139,54 +242,61 @@ <tr> <td class="ToolTopSeperator"></td> </tr> - <tr> + <tr class="s8"> <td> - <table class="PropertiesSheet" style="border: 0; padding: 0; border-spacing: 0; border-spacing: 2px;"> + <table class="PropertiesSheet" cellspacing="0" cellpadding="2"> <tr class='TableOtherLine'> <td class="s8b"> - <label for="Mode" class="i18n">閫夋嫨鍥惧眰</label> + <label for="Mode" class="i18n">瑕佺礌鎬讳釜鏁�</label> </td> - <td> <select id="LayerId" onchange="changeLayer(this);" style="width: 200pt;"></select> - <span id="refresh" onclick="refreshList();" style="text-decoration: underline; cursor: pointer;" class="i18n">鍒锋柊</span> + <td> <span id="totalNum">0</span> 涓� </td> </tr> <tr> <td class="s8b"> - <label for="Mode" class="i18n">缂撳啿璺濈</label> + <label for="Mode" class="i18n">绾垮璞¢暱搴�</label> </td> - <td> <input id="Buffer" type="text" style="width: 95pt;" value="0" size="7" onchange="CheckNumberEx(Buffer, 0, 0, 9999999); changeBuffer(this);" /> - 绫� + <td> <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> <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> <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> <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> <span id="volume">0</span> 绔嬫柟绫� + </td> + </tr> + <tr> + <td class="s8b"> + <label for="Mode" class="i18n">涓夌淮浣撻珮搴�</label> + </td> + <td> 鏈�浣� <span id="minHeight">0</span> 绫筹紝鏈�楂� <span id="maxHeight">0</span> 绫� + </td> + </tr> + <tr> + <td class="s8b"> + <label for="Mode" class="i18n">楂樺害瀛楁</label> + </td> + <td> <input id="hField" type="text" value="GD" /> </td> </tr> </table> </td> </tr> - <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;"> -- Gitblit v1.9.3