| | |
| | | } |
| | | } |
| | | |
| | | 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文件"); |
| | | |
| | |
| | | /// <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) |