管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2023-08-29 f0586817d86bb5b86efce42230e872fd9a254d69
1
已修改5个文件
118 ■■■■■ 文件已修改
DataLoader/CS/GdalHelper.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Controllers/ConvertController.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Web.config 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/Tools.cs 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/XYZUtils.cs 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/CS/GdalHelper.cs
@@ -26,7 +26,7 @@
        public static string MOON200 = "GCS_Moon_2000";
        public static List<string> EPSGS = new List<string>() { "EPSG:4326", "EPSG:4490", "ESRI:104903" };
        public static List<string> EPSGS = new List<string>() { "EPSG:4326", "EPSG:4490", "EPSG:104903" };
        /// <summary>
        /// 构造函数
@@ -116,7 +116,7 @@
                vd.Meta.coor_sys = sr.GetName(); // 坐标系统
                if (MOON200 == vd.Meta.coor_sys)
                {
                    vd.Meta.epsg = "ESRI:104903"; // EPSG编码
                    vd.Meta.epsg = "EPSG:104903"; // EPSG编码
                }
                else
                {
ExportMap/Controllers/ConvertController.cs
@@ -2,6 +2,7 @@
using ExportMap.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
@@ -17,7 +18,9 @@
            //string name = "8-瑞丽站0.05m.cpt";
            //string cnName = name.Substring(0, name.LastIndexOf("."));
            return Tools.GetLocalIP();
            //return Tools.GetLocalIP();
            return Tools.GetEPSG("D:\\Moon\\data\\dem_tif\\ldem.tif");
        }
        /// <summary>
@@ -303,6 +306,18 @@
        }
        [HttpGet]
        public string GetRasterEPSG(int id)
        {
            SysMeta meta = XYZUtils.SelectMeta(id);
            if (null == meta || string.IsNullOrEmpty(meta.path)) return null;
            string file = Path.Combine(Tools.GetSetting("uploadFolder"), meta.path);
            if (!File.Exists(file)) return null;
            return Tools.GetEPSG(file);
        }
        /// <summary>
        /// 检查参数
        /// </summary>
ExportMap/Web.config
@@ -26,6 +26,8 @@
    <add key="d3tilesPath" value="E:\WebSite\Cesium\Tool\3dtiles" />
    <!-- gocesiumtiler路径 -->
    <add key="tilerPath" value="E:\WebSite\Cesium\Tool\gocesiumtiler-1.2.3" />
    <!-- GDAL路径 -->
    <add key="gdalPath" value="E:\terrait\TianJin\Zip\release-1928-x64-dev\release-1928-x64\bin" />
    <!-- Mpt路径 -->
    <add key="mpt" value="D:\LF\data\mpt\tb.mpt" />
    <!-- PG连接 -->
ExportMap/cs/Tools.cs
@@ -6,6 +6,7 @@
using System.Configuration;
using System.Data.Common;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
@@ -16,7 +17,7 @@
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Web;
using System.Web.WebSockets;
namespace ExportMap.cs
{
@@ -197,7 +198,7 @@
        /// <returns>执行结果或出错信息</returns>
        public static string ExecCmd(SysTask task, List<string> list, bool isOut = false)
        {
            string str = null;
            string str;
            try
            {
                Process p = new Process();
@@ -304,7 +305,58 @@
                if (p != null)
                {
                    p.Close();
                    p = null;
                }
            }
            return str;
        }
        /// <summary>
        /// 执行命令
        /// </summary>
        public static string ExecCmd(List<string> list, ref string rs)
        {
            string str = null;
            Process p = null;
            try
            {
                p = new Process();
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.CreateNoWindow = true;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
                p.Start();
                StreamWriter si = p.StandardInput;
                StreamReader so = p.StandardOutput;
                StreamReader se = p.StandardError;
                LogOut.Info("cmd = " + string.Join(",", list));
                si.AutoFlush = true;
                foreach (string cmd in list)
                {
                    si.WriteLine(cmd);
                }
                si.WriteLine("exit");
                rs = so.ReadToEnd();
                str = se.ReadToEnd();
                se.Close();
                so.Close();
                si.Close();
            }
            catch (Exception ex)
            {
                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
                str = ex.Message;
            }
            finally
            {
                if (p != null)
                {
                    p.Close();
                }
            }
            return str;
@@ -345,6 +397,30 @@
        }
        /// <summary>
        /// 获取EPSG代码
        /// </summary>
        public static string GetEPSG(string file)
        {
            string gdalPath = GetSetting("gdalPath");
            string cmd = string.Format("{0}\\gdalsrsinfo.exe \"{1}\" -o epsg", gdalPath, file);
            string rs = null;
            string ostr = ExecCmd(new List<string> { cmd }, ref rs);
            if (string.IsNullOrEmpty(rs)) return null;
            string[] strs = rs.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string str in strs)
            {
                if (str.Contains("EPSG:"))
                {
                    return str;
                }
            }
            return null;
        }
        /// <summary>
        /// 设置单体模型参数
        /// </summary>
        public static void SetIsModel(XYZArgs args, List<SysMeta> list)
ExportMap/cs/XYZUtils.cs
@@ -128,6 +128,19 @@
        }
        /// <summary>
        /// 根据ID查询元数据
        /// </summary>
        public static SysMeta SelectMeta(int id)
        {
            string sql = string.Format("select a.*, fn_get_fullname(dircode, 2) dirname from lf.sys_meta a where id = {0}", id);
            DataTable dt = Tools.DBHelper.GetDataTable(sql);
            List<SysMeta> list = ModelHandler.FillModel<SysMeta>(dt);
            return null == list || list.Count == 0 ? null : list[0];
        }
        /// <summary>
        /// 写文本文件
        /// </summary>
        private static void WriteText(string file, List<SysMeta> list, List<int> mids)