管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2024-09-07 8d7a67ab1d635cb954337d8a767878ae526dd3dc
ExportMap/cs/OsgbUtils.cs
@@ -23,7 +23,7 @@
        /// </summary>
        public static string GetReleaseUrl(SysMeta meta)
        {
            return "http://{host}/LFData/3d/3dtiles/osgb/" + meta.id + "/tileset.json";
            return "{host}/LFData/3d/3dtiles/osgb/" + meta.id + "/tileset.json";
        }
        /// <summary>
@@ -56,9 +56,16 @@
                    if (!Directory.Exists(outPath)) Directory.CreateDirectory(outPath);
                    if (File.Exists(jsonFile)) File.Delete(jsonFile);
                    string cmd = string.Format("{0}\\3dtile.exe -f osgb -i \"{1}\" -o \"{2}\" -c \"{{\\\"offset\\\": {3}}}\"", d3tilesPath, osgbPath, outPath, args.z);
                    err = Tools.ExecCmd(cmd, false, false);
                    string srs = findSRS(osgbPath);
                    if (null != srs) writeSRS(osgbPath, getSRS(srs));
                    int idx = args.ids.IndexOf(meta.id);
                    string cmd = string.Format("{0}\\3dtile.exe -f osgb -i \"{1}\" -o \"{2}\" -c \"{{\\\"offset\\\": {3}}}\"", d3tilesPath, osgbPath, outPath, args.zs[idx]);
                    SysTask task = TaskDBHelper.CreateTask(args, meta, "OSGB", "倾斜数据(OSGB)");
                    err = Tools.ExecCmd(task, cmd, false);
                    err = null;
                    if (null != srs) writeSRS(osgbPath, srs);
                    if (File.Exists(jsonFile))
                    {
                        string path = jsonFile.Replace(Tools.GetSetting("lfData") + "\\", "");
@@ -78,15 +85,75 @@
        }
        /// <summary>
        /// 查找SRS
        /// </summary>
        private static string findSRS(string osgbPath)
        {
            string file = Path.Combine(osgbPath, "metadata.xml");
            if (!File.Exists(file)) return null;
            string[] lines = File.ReadAllLines(file);
            foreach (string line in lines)
            {
                if (line.Contains("<SRS>EPSG:") && line.Contains("+"))
                {
                    return line;
                }
            }
            return null;
        }
        /// <summary>
        /// 写入SRS
        /// </summary>
        private static void writeSRS(string osgbPath, string newSRS)
        {
            string file = Path.Combine(osgbPath, "metadata.xml");
            if (!File.Exists(file)) return;
            string[] lines = File.ReadAllLines(file);
            for (int i = 0, c = lines.Length; i < c; i++)
            {
                if (lines[i].Contains("<SRS>EPSG:"))
                {
                    lines[i] = newSRS;
                    break;
                }
            }
            File.WriteAllLines(file, lines);
        }
        /// <summary>
        /// 获取SRS
        /// </summary>
        /// <param name="srs"></param>
        private static string getSRS(string srs)
        {
            int start = srs.IndexOf("+");
            int end = srs.IndexOf("</SRS>");
            string other = srs.Substring(start, end - start);
            return srs.Replace(other, "");
        }
        /// <summary>
        /// 插入数据库
        /// </summary>
        private static int InsertToDB(SysMeta meta, XYZArgs args, string path)
        {
            if (PubDBHelper.IsPublish(meta.id)) return 0;
            //if (PubDBHelper.IsPublish(meta.id)) return 1;
            int pubid = PubDBHelper.GetPushlishId(meta.id);
            if (pubid > 0)
            {
                PubDBHelper.UpdatePublish(pubid, meta.name, args.userId, null);
                return pubid;
            }
            SysPublish sys = Tools.NewPublish(meta, args, GetReleaseUrl(meta), path);
            int pubid = PubDBHelper.InsertPublish(sys);
            pubid = PubDBHelper.InsertPublish(sys);
            if (pubid > 0)
            {
                sys.id = pubid;