| | |
| | | string uploadFolder = Tools.GetSetting("uploadFolder"); |
| | | foreach (SysMeta meta in metas) |
| | | { |
| | | if (metsIds.Contains(meta.id)) return PrintInfo("元数据[" + meta.id + "] 已发布。"); |
| | | |
| | | if (metsIds.Contains(meta.id)) |
| | | { |
| | | PrintInfo("元数据[" + meta.id + "] 已发布。"); |
| | | continue; |
| | | } |
| | | string sourceFile = Path.Combine(uploadFolder, meta.path); |
| | | if (!File.Exists(sourceFile)) return PrintInfo("元数据[" + meta.id + "] 不存在。"); |
| | | if (!File.Exists(sourceFile)) |
| | | { |
| | | PrintInfo("元数据[" + meta.id + "] 不存在。"); |
| | | continue; |
| | | } |
| | | |
| | | string targetFile = Path.Combine(subPath, meta.name); |
| | | string targetFile = Path.Combine(subPath, meta.path.Split(new string[] { "\\", "//" }, StringSplitOptions.None)[1]); |
| | | ConvertRaster(sourceFile, targetFile); |
| | | if (File.Exists(targetFile)) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | string vrt = CreateLayerJson(args, files, ref err); |
| | | |
| | | CreateLayerJson(args, files, ref err); |
| | | string json = Path.Combine(dirPath, "layer.json"); |
| | | if (!File.Exists(json)) return PrintInfo("找不到layer.json文件"); |
| | | |
| | |
| | | if (!ids.Contains(m.id)) PubDBHelper.InsertMetaPub(m.id, pubid, args.userId); |
| | | } |
| | | string geom = GetPointZ(args); |
| | | PubDBHelper.UpdatePublish(pubid, args.name, args.userId, geom); |
| | | int rows = PubDBHelper.UpdatePublish(pubid, args.name, args.userId, geom); |
| | | |
| | | return pubid; |
| | | } |
| | |
| | | /// <summary> |
| | | /// 获取中心点 |
| | | /// </summary> |
| | | private static string GetPointZ(XYZArgs args) |
| | | public static string GetPointZ(XYZArgs args) |
| | | { |
| | | double x = 0, y = 0; |
| | | string dirPath = GetTerrainPath(args.dircode); |
| | | string vrt = Path.Combine(dirPath, "subs", "dem.vrt"); |
| | | if (!File.Exists(vrt)) return null; |
| | | |
| | | string gdalPath = Tools.GetSetting("gdalPath"); |
| | | string cmd = string.Format("\"{0}\\gdalinfo.exe\" \"{1}\"", gdalPath, vrt); |
| | | |
| | | string rs = null; |
| | | Tools.ExecCmd(new List<string> { cmd }, ref rs); |
| | | string center = GetCenter(rs); |
| | | if (string.IsNullOrEmpty(rs)) return null; |
| | | |
| | | string[] strs = center.Split(new string[] { "," }, StringSplitOptions.None); |
| | | double x = double.Parse(strs[0]); |
| | | double y = double.Parse(strs[1]); |
| | | |
| | | return string.Format("ST_GeomFromText('POINT Z ({0} {1} {2})')", x, y, 12); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取中心坐标 |
| | | /// </summary> |
| | | private static string GetCenter(string rs) |
| | | { |
| | | if (string.IsNullOrEmpty(rs)) return null; |
| | | |
| | | string[] strs = rs.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); |
| | | foreach (string str in strs) |
| | | { |
| | | if (str.StartsWith("Center ")) |
| | | { |
| | | int start = str.IndexOf("("); |
| | | int end = str.IndexOf(")"); |
| | | |
| | | return str.Substring(start + 1, end - start - 1).Replace(" ", ""); |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 重投影 |
| | | /// </summary> |
| | | public static void Reproject(string sourceFile, string targetFile, string sourceSrs, string targetSrs) |