管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2023-06-27 c80a20113b16f70a8bc5d33bc68e8739ac4d33d6
1
已修改2个文件
205 ■■■■■ 文件已修改
ExportMap/UE.html 170 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/TBUtils.cs 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/UE.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>UE接口测试</title>
  <meta http-equiv="Expires" content="0" />
@@ -60,9 +61,11 @@
    // 坐标转化
    function transform() {
      var trans = new TUTransForm({ x: 117.038112825, y: 39.382696649 });
      trans.transformWGS84ToLocal();
      trans.transformLocalToWGS84();
      var coordinate = { x: 117.038112825, y: 39.382696649 }
      var Wgs84ToLocal = map.transformWGS84ToLocal(coordinate.x, coordinate.y)
      console.log('Wgs84ToLocal', Wgs84ToLocal)
      var LocalToWGS84 = map.transformLocalToWGS84(Wgs84ToLocal.x, coordinate.y)
      console.log('LocalToWGS84', LocalToWGS84)
    }
    // 获取镜头信息
@@ -94,13 +97,13 @@
    // 天气特效
    function setWeather() {
      // sun-晴天 ,rain-雨天,snow-雪天
      map.setWeather("snow");
      map.setWeather('rain') // 晴天
    }
    // 时间特效
    function setTime() {
      // morning-早晨,noon-中午,evening-傍晚,night-夜晚,darkWorld-暗色场景
      map.setTime("night");
      map.setTime("evening");
    }
    // 文字标签
@@ -120,11 +123,8 @@
      };
      var lbl = map.createLabel(options);
      lbl.show(true); // 显示
      // lbl.show(true); // 显示
      // lbl.show(false); // 隐藏
      // lbl.removeFromMap(); //  移除
      // map.removeLabel(lbl.id); //  移除
    }
    // POI点
@@ -138,9 +138,9 @@
        clickedScale: 0.7, // 点击后比例
        visibility: true, // 默认是否显示
        alertWindow: { // 可选,点击弹窗
          url: "http://localhost/testAlertWindow.html", // 弹窗地址
          size: new Vector2(180, 90), // 弹窗大小
          offset: new Vector2(50, -100) // 弹窗位置,右:x正,下:y正
          url: "http://192.168.20.89:12306/popupThree.html", // 弹窗地址
          size: new TUVector2(180, 90), // 弹窗大小
          offset: new TUVector2(50, -100) // 弹窗位置,右:x正,下:y正
        }
      }
@@ -158,46 +158,76 @@
    // 3DPOI点
    function create3DBillboard() {
      var param = {
        x: 1000, // x轴ue4坐标
        y: 1000, // y轴ue4坐标
        z: 0, // z轴ue4坐标
        image: "http://www.terra-it.cn/images/tubiao/indexLogo.png", // 图片地址
        scale: 0.5,//缩放
        clickedScale: 0.7,
        visibility: true, // 默认是否显示
        alertWindow: { // 可选,点击弹窗
          url: "http://localhost/testAlertWindow.html", // 弹窗地址
          size: new Vector2(180, 90), // 弹窗大小
          offset: new Vector2(50, -100) // 弹窗位置,右:x正,下:y正
        }
      }
      var testPoints = [{ "x": 10000, "y": 10000, "z": 4000 }];
      var points = []
      testPoints.forEach(function (item) {
        points.push({
          x: item.x,
          y: item.y,
          z: item.z,
          image: "http://www.terra-it.cn/images/tubiao/indexLogo.png",
          text: "",
          scale: 20,
          clickedScale: 1,
          flash: false,
          canClick: true,
      var poi = map.create3DBillboard(param);
      poi.show(true); // 显示
      var enable = true; // 是/否开启回调
      poi.Enable3DBillboardCallBack(enable, function (data) {
        console.info(data);
        });
      });
      poi = map.create3DBillboard(points)
      poi.forEach(function (b) {
        b.show(true)
      })
      var enable = true; // 是/否开启回调
      obj = obj.concat(poi);
      // poi.show(false); // 隐藏
      // poi.removeFromMap(); //  移除
    }
    function creat() {
      map.Enable3DBillboardCallBack(true, function (e) {
        console.log(e, "11111111111")
      })
    }
    // 添加线路
    function createPolyline() {
      var obj = map.createPolyline({
        pathWidth: 1000, // 路径宽度
        pathColor: "#00FF00", // 路径颜色
        type: 1, // 线路类型: 0高亮 1三角 2箭头
        data: [ // 路径点位数组,ue4坐标
            new TUVector3(-129.99, -7.41, 0),
            new TUVector3(-131.00, -134.96, 0),
            new TUVector3(113.83, -128.26, 0),
            new TUVector3(123.84, -550.99, 0)
        ]
      // var obj = map.createPolyline({
      //   pathWidth: 1000, // 路径宽度
      //   pathColor: "#00FF00", // 路径颜色
      //   type: 1, // 线路类型: 0高亮 1三角 2箭头
      //   data: [ // 路径点位数组,ue4坐标
      //     new TUVector3(-129.99, -7.41, 0),
      //     new TUVector3(-131.00, -134.96, 0),
      //     new TUVector3(113.83, -128.26, 0),
      //     new TUVector3(123.84, -550.99, 0)
      //   ]
      // });
      var testPoints = [
        new TUVector3(77053.6953125, 150984.859375, 0),
        new TUVector3(16167.91015625, 151470.453125, 0),
        new TUVector3(14827.0908203125, 100942.328125, 0),
        new TUVector3(71444.015625, 104834.4375, 0),
        new TUVector3(67891.890625, 57269.85546875, 0),
        new TUVector3(13084.04296875, 56401.7734375, 0),
        new TUVector3(11550.640625, -13705.76953125, 0),
        new TUVector3(7773.74560546875, -103738.140625, 0),
      ];
      testPointArray = []
      //绘制路径
      pathObj = map.createPolyline({
        data: testPoints,
        pathWidth: 3000,
        type: 0,//0高亮线 1三角 2箭头
        pathColor: "cyan",
      });
      var roll = 0, pitch = -45, yaw = 0, distance = 1000;
      var callBack = function () { console.log("flyTo"); }
      var time = 3; // 3s
      map.flyTo(116.51446997, 39.772785555, 1000, roll, pitch, yaw, distance, callBack, time);
    }
    // 添加区域
@@ -235,10 +265,10 @@
        color: "#ff0000", // 默认白色
        brightness: 10, // 默认10
        data: [ // 围栏点位数组 
            new TUVector3(-129.99, -7.41, 0),
            new TUVector3(-131.00, -134.96, 0),
            new TUVector3(113.83, -128.26, 0),
            new TUVector3(123.84, -550.99, 0)
          new TUVector3(-129.99, -7.41, 0),
          new TUVector3(-131.00, -134.96, 0),
          new TUVector3(113.83, -128.26, 0),
          new TUVector3(123.84, -550.99, 0)
        ]
      }
      var bound = map.createAreaBoundary(param);
@@ -271,29 +301,38 @@
    // 拾取坐标
    function pickPosition() {
      map.pickPosition(function (e) {
        alert(JSON.stringify(e)); // e.objectName-内部编号,e.location-点位的ue4坐标
        map.endPick(); // 取消拾取
      });
      // map.pickPosition(function (e) {
      //   alert(JSON.stringify(e)); // e.objectName-内部编号,e.location-点位的ue4坐标
      //   map.endPick(); // 取消拾取
      // });
      var vla = map.transformLocalToWGS84(map.camera.location.x, map.camera.location.y);
      alert(JSON.stringify(vla))
    }
    // 拾取对象
    function pickObject() {
      map.execute("factory", "callEvent", { eventName: "ClickObjectCallBack", param: "1" }, function (e) {
        console.log(e);
        map.execute("factory", "callEvent", { eventName: "ClickObjectCallBack", param: "0" }, null); // 取消拾取
      map.pickPosition(function (e) {
        if (e) {
          alert(JSON.stringify(e))
        }
      });
      // map.execute("factory", "callEvent", { eventName: "ClickObjectCallBack", param: "1" }, function (e) {
      //   console.log(e);
      //   map.execute("factory", "callEvent", { eventName: "ClickObjectCallBack", param: "0" }, null); // 取消拾取
      // });
    }
    // 清除
    function clear() {
      map.resetWeather(); // 移除天气特效
      map.resetTime(); // 移除时间特效
      map.clearAllCovering(); // 清除所有覆盖物
    function objclear() {
      map.clearAllCovering();
    }
  </script>
</head>
<body>
  <div id="map"></div>
@@ -302,21 +341,22 @@
    <button onclick="getCamera();">获取镜头信息</button>
    <button onclick="flyTo();">飞行</button>
    <button onclick="setView();">切换镜头</button>
    <button onclick="setWeather();">天气特效</button>
    <!-- <button onclick="setWeather();">天气特效</button> -->
    <button onclick="setTime();">时间特效</button>
    <button onclick="createLabel();">文字标签</button>
    <button onclick="createBillboard();">POI点</button>
    <button onclick="create3DBillboard();">3DPOI点</button>
    <button onclick="createPolyline();">添加线路</button>
    <!-- <button onclick="createPolyline();">添加线路</button> -->
    <button onclick="createAreaData();">添加区域</button>
    <button onclick="createCircleArea();">光圈</button>
    <button onclick="createAreaBoundary();">围栏</button>
    <button onclick="getMeasureHeight();">高度量测</button>
    <!-- <button onclick="getMeasureHeight();">高度量测</button>
    <button onclick="getDistanceHorizontal();">折线距离量测</button>
    <button onclick="getPlaneArea();">平面面积量测</button>
    <button onclick="pickPosition();">拾取坐标</button>
    <button onclick="getPlaneArea();">平面面积量测</button> -->
    <button onclick="pickPosition();">获取镜头坐标</button>
    <button onclick="pickObject();">拾取对象</button>
    <button onclick="clear();">清除</button>
    <button onclick="objclear();">清除</button>
  </div>
</body>
</html>
</html>
ExportMap/cs/TBUtils.cs
@@ -75,7 +75,7 @@
            }
            finally
            {
                ending(time);
                ending(time, sourcePath);
            }
        }
@@ -97,15 +97,15 @@
        /// </summary>
        private static void MoveFilesToTemp(string sourcePath, string targetPath)
        {
            CopyFolder(Path.Combine(sourcePath, "数字正射影像图"), Path.Combine(targetPath, "img"));
            CopyFolder(Path.Combine(sourcePath, "数字高程模型"), Path.Combine(targetPath, "dem"));
            CopyFolder(Path.Combine(sourcePath, "中线裁剪范围"), Path.Combine(targetPath, "shp"));
            MoveFolder(Path.Combine(sourcePath, "数字正射影像图"), Path.Combine(targetPath, "img"));
            MoveFolder(Path.Combine(sourcePath, "数字高程模型"), Path.Combine(targetPath, "dem"));
            MoveFolder(Path.Combine(sourcePath, "中线裁剪范围"), Path.Combine(targetPath, "shp"));
        }
        /// <summary>
        /// 复制目录
        /// 移动目录
        /// </summary>
        private static void CopyFolder(string sourcePath, string targetPath)
        private static void MoveFolder(string sourcePath, string targetPath)
        {
            if (!Directory.Exists(targetPath)) Directory.CreateDirectory(targetPath);
@@ -191,19 +191,34 @@
        /// <summary>
        /// 收尾工作
        /// </summary>
        private static void ending(string time)
        private static void ending(string time, string sourcePath)
        {
            try
            {
                string targetPath = Path.Combine(Tools.TempDir, time);
                if (!Directory.Exists(targetPath)) return;
                string path = Path.Combine(Tools.TempDir, time);
                if (!Directory.Exists(path)) return;
                //
                string img = GetFilePath(Path.Combine(path, "img"), "*.tif");
                if (null != img) MoveFile(img, Path.Combine(sourcePath, "数字正射影像图"));
                string dem = GetFilePath(Path.Combine(path, "dem"), "*.tif");
                if (null != dem) MoveFile(dem, Path.Combine(sourcePath, "数字高程模型"));
                MoveFolder(Path.Combine(path, "shp"), Path.Combine(sourcePath, "中线裁剪范围"));
            }
            catch (Exception ex)
            {
                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
        /// <summary>
        /// 移动文件
        /// </summary>
        private static void MoveFile(string file, string targetPath)
        {
            FileInfo fi = new FileInfo(file);
            File.Move(file, Path.Combine(targetPath, fi.Name));
        }
    }
}