123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- <!-- 2017-12-4 14:24:12 | 修改 木遥(微信: http://marsgis.cn/weixin.html ) -->
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
- <meta name="apple-touch-fullscreen" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-status-bar-style" content="black" />
- <meta name="format-detection" content="telephone=no" />
- <meta name="x5-fullscreen" content="true" />
- <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
- <!-- 标题及搜索关键字 -->
- <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
- <meta
- name="description"
- content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型 gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包 地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
- />
- <link rel="shortcut icon" type="image/x-icon" href="" />
- <title>方量分析(体积) </title>
- <script
- type="text/javascript"
- src="../lib/include-lib.js"
- libpath="../lib/"
- include="jquery,font-awesome,bootstrap,bootstrap-checkbox,layer,haoutil,turf,mars3d"
- ></script>
- <link href="css/style.css" rel="stylesheet" />
- <style>
- .sectionChars {
- top: auto;
- width: 90%;
- height: 200px;
- bottom: 10px;
- left: 5%;
- top: auto;
- bottom: 10px;
- display: none;
- }
- #fillHeight {
- height: 34px;
- position: relative;
- top: 1px;
- border-radius: 3px;
- }
- .infoview div {
- margin-bottom: 5px;
- }
- </style>
- </head>
- <body class="dark">
- <!--加载前进行操作提示,优化用户体验-->
- <div id="mask" class="signmask" onclick="removeMask()"></div>
- <div id="mars3dContainer" class="mars3d-container"></div>
- <!-- 面板 -->
- <div class="infoview">
- <div>
- <span style="color: #cad1d1">
- 提示:单击分析按钮激活绘制分析,对绘制面(墙)内的进行以下计算。<br />
- 1. 挖方量: 计算“基准面”到地表之间的凸出部分进行挖掉的体积。<br />
- 2. 填方量:计算“基准面”与“墙底部”之间的缺少部分进行填平的体积。
- </span>
- </div>
- <div>
- <input id="measure" type="button" class="btn btn-primary" value="方量分析" />
- <input id="clear" type="button" class="btn btn-info" value="清除" />
- <div class="checkbox checkbox-primary checkbox-inline">
- <input id="chkShowPolygonInter" class="styled" type="checkbox" />
- <label for="chkShowPolygonInter"> 显示面内计算的三角网(测试) </label>
- </div>
- </div>
- <div>
- 基准面高:
- <input id="txtHeight" type="number" value="0" step="0.1" class="form-control" style="width: 100px" />(米)
- <input id="selHeight" type="button" class="btn btn-primary" value="点选高度" />
- </div>
- <div>
- 围墙底高:
- <input id="txtMinHeight" type="number" value="0" step="0.1" class="form-control" style="width: 100px" />(米)
- </div>
- <div title="围墙顶高只是展示效果,与计算结果无关。">
- 围墙顶高:
- <input id="txtMaxHeight" type="number" value="0" step="0.1" class="form-control" style="width: 100px" />(米)
- </div>
- </div>
- <!-- 切换视角到模型或地形(山区)的快捷按钮 -->
- <script type="text/javascript" src="js/center_terrain_3dtiles.js"></script>
- <script src="js/showPolygonInter.js"></script>
- <script src="./js/common.js"></script>
- <script type="text/javascript">
- "use script"; //开发环境建议开启严格模式
- var map;
- var measure;
- var measureVolume;
- function initMap(options) {
- //合并属性参数,可覆盖config.json中的对应配置
- var mapOptions = mars3d.Util.merge(options, {
- scene: {
- globe: { depthTestAgainstTerrain: true },
- center: { lat: 30.883785, lng: 116.230883, alt: 8121, heading: 266, pitch: -62 },
- },
- });
- //创建三维地球场景
- map = new mars3d.Map("mars3dContainer", mapOptions);
- measure = new mars3d.thing.Measure({
- label: {
- color: "#ffffff",
- font_family: "楷体",
- font_size: 20,
- },
- });
- map.addThing(measure);
- //直接传入坐标分析
- measureVolume = measure.volume({
- positions: mars3d.PointTrans.lonlats2cartesians([
- [116.191817, 30.864845, 309.3],
- [116.192869, 30.8757, 521.81],
- [116.190478, 30.886266, 672.79],
- [116.19247, 30.893748, 448.91],
- [116.200836, 30.889954, 379.92],
- [116.204063, 30.882578, 532.5],
- [116.203027, 30.873828, 498.8],
- [116.201795, 30.865941, 443.06],
- ]),
- splitNum: 6,
- height: 450,
- });
- measure.on(mars3d.EventType.start, function (event) {
- console.log("开始分析", event);
- clearInterResult(); //在js/showPolygonInter.js
- haoutil.loading.show();
- //打印下边界,测试用
- var coords = mars3d.PointTrans.cartesians2lonlats(event.positions);
- console.log(JSON.stringify(coords));
- });
- measure.on(mars3d.EventType.end, function (event) {
- console.log("分析完成", event);
- haoutil.loading.close();
- showHeightVal(event.sourceTarget);
- //显示结果
- var showResult = $("#chkShowPolygonInter").is(":checked");
- if (showResult) {
- showInterResult(event.list); //在js/showPolygonInter.js
- }
- });
- $("#measure").click(function () {
- //手动绘制的方式分析
- measureVolume = measure.volume({
- splitNum: 6, //面内插值次数,控制精度[注意精度越大,分析时间越长]
- // minHeight: 50 //可以设置一个固定的最低高度
- });
- });
- $("#clear").click(function () {
- measure.clear();
- clearInterResult(); //在js/showPolygonInter.js
- });
- $("#txtHeight").change(function () {
- var num = Number($(this).val());
- measureVolume.height = num;
- showHeightVal();
- });
- $("#txtMinHeight").change(function () {
- var num = Number($(this).val());
- if (num > measureVolume.height) {
- haoutil.msg("墙底部高度不能高于基准面高");
- $("#txtMinHeight").val(measureVolume.minHeight.toFixed(1));
- return;
- }
- measureVolume.minHeight = num;
- });
- $("#txtMaxHeight").change(function () {
- var num = Number($(this).val());
- var maxHeight = getFixedNum(measureVolume.polygonMaxHeight);
- if (num < maxHeight) {
- haoutil.msg("墙顶部高度不能低于区域内的地表高" + maxHeight);
- $("#txtMaxHeight").val(maxHeight);
- measureVolume.maxHeight = Number(maxHeight);
- return;
- }
- if (num < measureVolume.height) {
- haoutil.msg("墙顶部高度不能低于基准面高");
- $("#txtMaxHeight").val(measureVolume.maxHeight.toFixed(1));
- return;
- }
- measureVolume.maxHeight = num;
- });
- $("#selHeight").click(function () {
- measureVolume.selecteHeight(showHeightVal);
- });
- $("#chkShowPolygonInter").change(function () {
- var showResult = $(this).is(":checked");
- if (showResult) {
- showInterResult(measureVolume.interPolygonObj.list); //在js/showPolygonInter.js
- } else {
- clearInterResult(); //在js/showPolygonInter.js
- }
- });
- }
- function showHeightVal() {
- $("#txtHeight").val(measureVolume.height.toFixed(1));
- $("#txtMinHeight").val(measureVolume.minHeight.toFixed(1));
- $("#txtMaxHeight").val(getFixedNum(measureVolume.maxHeight));
- }
- function getFixedNum(val) {
- return Math.ceil(val * 10) / 10;
- }
- </script>
- </body>
- </html>
|