From d9c6232dac8c1af6586d116fe558d154feb46011 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 21 六月 2023 15:50:22 +0800 Subject: [PATCH] 1 --- ExportMap/cs/OsgbUtils.cs | 82 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 79 insertions(+), 3 deletions(-) diff --git a/ExportMap/cs/OsgbUtils.cs b/ExportMap/cs/OsgbUtils.cs index 4c90fa9..8053cfa 100644 --- a/ExportMap/cs/OsgbUtils.cs +++ b/ExportMap/cs/OsgbUtils.cs @@ -1,6 +1,8 @@ -锘縰sing ExportMap.Models; +锘縰sing ExportMap.db; +using ExportMap.Models; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Web; @@ -9,6 +11,22 @@ public class OsgbUtils { /// <summary> + /// 鑾峰彇璺緞 + /// </summary> + public static string GetPath(int id) + { + return Path.Combine(SGUtils.LFData, "3d\\3dtiles\\osgb", id.ToString()); + } + + /// <summary> + /// 鑾峰彇鍙戝竷鍦板潃 + /// </summary> + public static string GetReleaseUrl(SysMeta meta) + { + return "http://{host}/LFData/3d/3dtiles/osgb/" + meta.id + "/tileset.json"; + } + + /// <summary> /// 鐢熸垚 /// </summary> /// <param name="args">XYZ鍙傛暟</param> @@ -16,9 +34,67 @@ /// <returns>鏁版嵁鍙戝竷ID闆嗗悎</returns> public static List<int> Generate(XYZArgs args, ref string err) { - // + try + { + List<SysMeta> list = XYZUtils.SelectMetas(args.ids, "and type = 'osgb'"); + if (null == list || list.Count == 0) return null; - return null; + string d3tilesPath = Tools.GetSetting("d3tilesPath"); + string uploadFolder = Tools.GetSetting("uploadFolder"); + + List<int> ids = new List<int>(); + foreach (SysMeta meta in list) + { + string osgbPath = Path.Combine(uploadFolder, meta.path); + if (!Directory.Exists(osgbPath)) continue; + + meta.ismeta = 0; // 0-鍊炬枩鎽勫奖鏁版嵁 + string outPath = GetPath(meta.id); + string jsonFile = Path.Combine(outPath, "tileset.json"); + + if (args.isNew && Directory.Exists(outPath)) Tools.DelPath(outPath); + 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}\"", d3tilesPath, osgbPath, outPath); + err = Tools.ExecCmd(cmd, false, false); + + if (File.Exists(jsonFile)) + { + string path = jsonFile.Replace(Tools.GetSetting("lfData") + "\\", ""); + int pubid = InsertToDB(meta, args, path); + if (pubid > 0) ids.Add(pubid); + } + } + + return ids; + } + catch (Exception ex) + { + LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); + err = ex.Message; + return null; + } + } + + /// <summary> + /// 鎻掑叆鏁版嵁搴� + /// </summary> + private static int InsertToDB(SysMeta meta, XYZArgs args, string path) + { + if (PubDBHelper.IsPublish(meta.id)) return 0; + + SysPublish sys = Tools.NewPublish(meta, args, GetReleaseUrl(meta), path); + + int pubid = PubDBHelper.InsertPublish(sys); + if (pubid > 0) + { + sys.id = pubid; + PubDBHelper.InsertLayer(sys, meta); + PubDBHelper.InsertMetaPub(meta.id, pubid, args.userId); + } + + return pubid; } } } -- Gitblit v1.9.3