| | |
| | | <Compile Include="cs\LogOut.cs" /> |
| | | <Compile Include="cs\NoBufferPolicySelector.cs" /> |
| | | <Compile Include="cs\SGUtils.cs" /> |
| | | <Compile Include="cs\Tool.cs" /> |
| | | <Compile Include="cs\Tools.cs" /> |
| | | <Compile Include="cs\XYZUtils.cs" /> |
| | | <Compile Include="db\ModelHandler.cs" /> |
| | | <Compile Include="db\PostgreHelper.cs" /> |
| | |
| | | public static int Convert(XYZArgs args) |
| | | { |
| | | int count = 0; |
| | | string uploadFolder = Tool.GetSetting("uploadFolder"); |
| | | string tilesFolder = Path.Combine(Tool.GetSetting("lfData"), "3d\\3dtiles"); |
| | | string uploadFolder = Tools.GetSetting("uploadFolder"); |
| | | string tilesFolder = Path.Combine(Tools.GetSetting("lfData"), "3d\\3dtiles"); |
| | | |
| | | List<SysMeta> list = XYZUtils.selectMetas(args.ids, "and type in ('ifc', 'fbx', 'rvt')"); |
| | | List<SysMeta> list = XYZUtils.SelectMetas(args.ids, "and type in ('ifc', 'fbx', 'rvt')"); |
| | | if (null == list || list.Count == 0) return 0; |
| | | |
| | | foreach (SysMeta meta in list) |
| | |
| | | string modelFile = Path.Combine(uploadFolder, meta.path); |
| | | if (!File.Exists(modelFile)) continue; |
| | | |
| | | string configFile = Path.Combine(Tool.TempDir, ExportUtil.DateStr + ".json"); |
| | | string configFile = Path.Combine(Tools.TempDir, ExportUtil.DateStr + ".json"); |
| | | string outPath = Path.Combine(tilesFolder, meta.type, meta.id.ToString()); |
| | | string jsonFile = Path.Combine(outPath, "tileset.json"); |
| | | |
| | |
| | | File.Delete(configFile); |
| | | if (File.Exists(jsonFile)) |
| | | { |
| | | string path = jsonFile.Replace(Tool.GetSetting("lfData") + "\\", ""); |
| | | string path = jsonFile.Replace(Tools.GetSetting("lfData") + "\\", ""); |
| | | InsertToDB(meta, args, path); |
| | | |
| | | count++; |
| | |
| | | { |
| | | if (string.IsNullOrEmpty(sourcesPath)) |
| | | { |
| | | sourcesPath = Path.Combine(Tool.BaseDir, "Sources"); |
| | | sourcesPath = Path.Combine(Tools.BaseDir, "Sources"); |
| | | } |
| | | |
| | | return sourcesPath; |
| | |
| | | CreateTemplate(args); |
| | | |
| | | string cmd = string.Format("python \"{0}\" -qgz {1} -qpt {2}", PyFile, qgz, args.qpt); |
| | | err = Tool.ExecCmd(cmd, true); |
| | | err = Tools.ExecCmd(cmd, true); |
| | | |
| | | string qptFile = Path.Combine(SourcesPath, args.qpt); |
| | | if (File.Exists(qptFile)) File.Delete(qptFile); |
| | |
| | | /// <returns>è¡æ°</returns> |
| | | public int Release(XYZArgs args, ref string err) |
| | | { |
| | | List<SysMeta> list = XYZUtils.selectMetas(args.ids, "and type in ('mpt', '3dml')"); |
| | | List<SysMeta> list = XYZUtils.SelectMetas(args.ids, "and type in ('mpt', '3dml')"); |
| | | if (null == list || list.Count == 0) return 0; |
| | | |
| | | int maxId = GetMaxId(); // maxId = 411576; |
| | |
| | | /// </summary> |
| | | private void RomoveNoneFiles(List<SysMeta> list) |
| | | { |
| | | string uploadFolder = Tool.GetSetting("uploadFolder"); |
| | | string uploadFolder = Tools.GetSetting("uploadFolder"); |
| | | |
| | | int i = 0; |
| | | while (i < list.Count) |
| | |
| | | /// </summary> |
| | | private static void MoveFiles(List<SysMeta> metas) |
| | | { |
| | | string uploadFolder = Tool.GetSetting("uploadFolder"); |
| | | string uploadFolder = Tools.GetSetting("uploadFolder"); |
| | | string sgFolder = Path.Combine(uploadFolder, "SG"); |
| | | if (!Directory.Exists(sgFolder)) Directory.CreateDirectory(sgFolder); |
| | | |
| | |
| | | |
| | | if (0 == list.Count) return "没æéè¦æ´æ°åå¸çæä»¶"; |
| | | |
| | | return Tool.ExecCmd(list); |
| | | return Tools.ExecCmd(list); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | private void AddMptLinkFile(List<string> list, SysMeta meta) |
| | | { |
| | | string uploadFolder = Tool.GetSetting("uploadFolder"); |
| | | string d3mlFolder = Tool.GetSetting("3dmlFolder"); |
| | | string uploadFolder = Tools.GetSetting("uploadFolder"); |
| | | string d3mlFolder = Tools.GetSetting("3dmlFolder"); |
| | | |
| | | string targetFolder = Path.Combine(d3mlFolder, meta.id.ToString()); |
| | | if (!Directory.Exists(targetFolder)) Directory.CreateDirectory(targetFolder); |
| | |
| | | /// </summary> |
| | | private void AddD3mlLinkFile(List<string> list, SysMeta meta) |
| | | { |
| | | string uploadFolder = Tool.GetSetting("uploadFolder"); |
| | | string mptFolder = Tool.GetSetting("mptFolder"); |
| | | string uploadFolder = Tools.GetSetting("uploadFolder"); |
| | | string mptFolder = Tools.GetSetting("mptFolder"); |
| | | |
| | | string targetFolder = Path.Combine(mptFolder, meta.id.ToString()); |
| | | if (!Directory.Exists(targetFolder)) Directory.CreateDirectory(targetFolder); |
ÎļþÃû´Ó ExportMap/cs/Tool.cs ÐÞ¸Ä |
| | |
| | | |
| | | namespace ExportMap.cs |
| | | { |
| | | public class Tool |
| | | public class Tools |
| | | { |
| | | /// <summary> |
| | | /// åºç¡ç®å½ |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// batè·¯å¾ |
| | | /// </summary> |
| | | public static string BatPath |
| | | { |
| | | get |
| | | { |
| | | return @"C:\Program Files\QGIS 3.16\bin\"; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºç¡batæä»¶ |
| | | /// </summary> |
| | | public static string BaseBat |
| | | { |
| | | get |
| | | { |
| | | // python-qgis-ltr.batï¼qgis_process-qgis-ltr.bat |
| | | return @"C:\Program Files\QGIS 3.16\bin\qgis_process-qgis-ltr.bat"; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·ååå¸å°å |
| | | /// </summary> |
| | | public static string GetReleaseUrl(string dircode) |
| | |
| | | /// <returns>æ°æ®åå¸ID</returns> |
| | | public static int Generate(XYZArgs args, ref string err) |
| | | { |
| | | List<SysMeta> list = selectMetas(args.ids, "and type in ('tif', 'tiff', 'img')"); |
| | | List<SysMeta> list = SelectMetas(args.ids, "and type in ('tif', 'tiff', 'img')"); |
| | | if (null == list || list.Count == 0) return 0; |
| | | |
| | | string tifFile = Path.Combine(Tool.TempDir, ExportUtil.DateStr + ".txt"); |
| | | string dateStr = ExportUtil.DateStr; |
| | | string batFile = Path.Combine(BatPath, dateStr + ".bat"); |
| | | string tifFile = Path.Combine(Tools.TempDir, ExportUtil.DateStr + ".txt"); |
| | | string xyzPath = Path.Combine(SGUtils.LFData, "2d\\tiles", args.dircode); |
| | | if (!Directory.Exists(xyzPath)) Directory.CreateDirectory(xyzPath); |
| | | |
| | |
| | | //string newPy = tifFile.Replace(".txt", ".py").Replace("\\", "\\\\"); |
| | | //File.WriteAllText(newPy, pyText); |
| | | //string cmd = string.Format("exec(open('{0}', 'r', encoding='utf-8').read()) & exit()", newPy); |
| | | //err = ExecCmd(cmd); |
| | | |
| | | err = ExecCmd(cmd); |
| | | //List<string> cmds = GetCmds(cmd); |
| | | //err = Tools.ExecCmd(cmds); |
| | | |
| | | List<string> cmds = GetCmds(batFile, cmd); |
| | | err = Tools.ExecCmd(cmds); |
| | | |
| | | if (File.Exists(tifFile)) File.Delete(tifFile); |
| | | if (File.Exists(batFile)) File.Delete(batFile); |
| | | |
| | | string viewFile = Path.Combine(xyzPath, "view.html"); |
| | | if (File.Exists(viewFile)) |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åå½ä»¤è¡ |
| | | /// </summary> |
| | | private static List<string> GetCmds(string batFile, string cmd) |
| | | { |
| | | string str = File.ReadAllText(BaseBat) + cmd; |
| | | File.WriteAllText(batFile, str); |
| | | |
| | | return new List<string>() { "\"" + batFile + "\"" }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢å
æ°æ® |
| | | /// </summary> |
| | | public static List<SysMeta> selectMetas(List<int> ids, string types = "") |
| | | public static List<SysMeta> SelectMetas(List<int> ids, string types = "") |
| | | { |
| | | string sql = string.Format("select * from lf.sys_meta where id in ({0}) {1} order by id", string.Join(",", ids), types); |
| | | DataTable dt = Tool.DBHelper.GetDataTable(sql); |
| | | DataTable dt = Tools.DBHelper.GetDataTable(sql); |
| | | List<SysMeta> list = ModelHandler.FillModel<SysMeta>(dt); |
| | | |
| | | return list; |
| | |
| | | /// </summary> |
| | | private static void WriteText(string file, List<SysMeta> list) |
| | | { |
| | | string uploadFolder = Tool.GetSetting("uploadFolder"); |
| | | string uploadFolder = Tools.GetSetting("uploadFolder"); |
| | | |
| | | List<string> files = new List<string>(); |
| | | foreach (SysMeta meta in list) |
| | | { |
| | | string filePath = Path.Combine(uploadFolder, meta.path); |
| | | if (File.Exists(filePath)) files.Add(filePath); |
| | | } |
| | | //foreach (SysMeta meta in list) |
| | | //{ |
| | | // string filePath = Path.Combine(uploadFolder, meta.path); |
| | | // if (File.Exists(filePath)) files.Add(filePath); |
| | | //} |
| | | files.Add(@"E:\01.Data\33.DOM\2.大åºDOM\5154.50-415.50.tif"); |
| | | files.Add(@"E:\01.Data\33.DOM\2.大åºDOM\5154.50-416.00.tif"); |
| | | string str = string.Join("\n", files); |
| | | |
| | | File.WriteAllText(file, str); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ§è¡CMD |
| | | /// </summary> |
| | | /// <param name="cmd">å½ä»¤è¡</param> |
| | | /// <returns>æ§è¡ç»ææåºéä¿¡æ¯</returns> |
| | | public static String ExecCmd(string cmd) |
| | | { |
| | | string str = null; |
| | | try |
| | | { |
| | | Process 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 = " + cmd); |
| | | si.AutoFlush = true; |
| | | si.WriteLine("cd \"C:\\Program Files\\QGIS 3.16\\apps\\Python37\""); |
| | | si.WriteLine("\"C:\\Program Files\\QGIS 3.16\\bin\\qgis_process-qgis-ltr.bat\""); |
| | | //si.WriteLine("\"C:\\Program Files\\QGIS 3.16\\bin\\python-qgis-ltr.bat\""); |
| | | //si.WriteLine("exit()"); |
| | | si.WriteLine(cmd); |
| | | si.WriteLine("exit"); |
| | | |
| | | string info = so.ReadToEnd(); |
| | | str = se.ReadToEnd(); |
| | | |
| | | if (!string.IsNullOrEmpty(info)) LogOut.Debug(info); |
| | | if (!string.IsNullOrEmpty(str)) LogOut.Error(str); |
| | | if (p.HasExited == false) p.Kill(); |
| | | |
| | | se.Close(); |
| | | so.Close(); |
| | | si.Close(); |
| | | p.Close(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.StackTrace); |
| | | str = ex.Message; |
| | | } |
| | | |
| | | return str; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | string sql = "select count(*) from lf.sys_meta_pub a inner join lf.sys_publish b on a.pubid = b.id where a.metaid = " + metaid; |
| | | |
| | | object obj = Tool.DBHelper.GetScalar(sql); |
| | | object obj = Tools.DBHelper.GetScalar(sql); |
| | | int count = obj == null ? 0 : Convert.ToInt32(obj); |
| | | |
| | | return count > 0; |
| | |
| | | string sql = "select count(*) from lf.sys_meta_pub a inner join lf.sys_publish b on a.pubid = b.id where b.type = 'DOM' and b.dirid = @dirid"; |
| | | DbParameter dp = new NpgsqlParameter("@dirid", dirid); |
| | | |
| | | object obj = Tool.DBHelper.GetScalar(sql, dp); |
| | | object obj = Tools.DBHelper.GetScalar(sql, dp); |
| | | int count = obj == null ? 0 : Convert.ToInt32(obj); |
| | | |
| | | return count > 0; |
| | |
| | | { |
| | | string sql = string.Format(insertMetaPubSql, metaid, pubid, userId); |
| | | |
| | | return Tool.DBHelper.ExecuteNonQuery(sql); |
| | | return Tools.DBHelper.ExecuteNonQuery(sql); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public static int InsertPublish(SysPublish sys) |
| | | { |
| | | List<DbParameter> list = Tool.GetParams<SysPublish>(insertPublishSql, sys); |
| | | List<DbParameter> list = Tools.GetParams<SysPublish>(insertPublishSql, sys); |
| | | string sql = string.Format(insertPublishSql, sys.geom == null ? "null" : sys.geom); |
| | | |
| | | object obj = Tool.DBHelper.GetScalar(sql, list.ToArray()); |
| | | object obj = Tools.DBHelper.GetScalar(sql, list.ToArray()); |
| | | |
| | | return obj == null ? 0 : Convert.ToInt32(obj); |
| | | } |
| | |
| | | list.Add(new NpgsqlParameter("@user", sys.create_user)); |
| | | list.Add(new NpgsqlParameter("@elev", elev)); |
| | | |
| | | int rows = Tool.DBHelper.ExecuteNonQuery(insertLayerSql, list.ToArray()); |
| | | int rows = Tools.DBHelper.ExecuteNonQuery(insertLayerSql, list.ToArray()); |
| | | |
| | | return rows; |
| | | } |
| | |
| | | list.Add(new NpgsqlParameter("@id", meta.id)); |
| | | list.Add(new NpgsqlParameter("@path", meta.path)); |
| | | |
| | | int rows = Tool.DBHelper.ExecuteNonQuery(updateMetaSql, list.ToArray()); |
| | | int rows = Tools.DBHelper.ExecuteNonQuery(updateMetaSql, list.ToArray()); |
| | | |
| | | return rows; |
| | | } |
| | |
| | | static SQLiteHelper() |
| | | { |
| | | //SQLiteHelper.DB = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources\\Community.db"); |
| | | DB = Tool.GetSetting("sgDB"); |
| | | DB = Tools.GetSetting("sgDB"); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | // æµè¯åå¾ |
| | | function convertXYZ() { |
| | | var data = { token: token, ids: [1526, 1527], id: 1, min: 12, max: 12, depcode: "000305", dircode: "0102", userId: 1, name: "DOM_0.2m" }; |
| | | var data = { token: token, ids: [1526, 1527], id: 1, min: 8, max: 18, depcode: "000305", dircode: "0102", userId: 1, name: "DOM_0.2m" }; |
| | | ajax("Convert/ToTiles", "POST", JSON.stringify(data), null, null, function (rs) { |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | console.log(rs); |