| | |
| | | { |
| | | private static string pyFile; |
| | | |
| | | private static int terrainMaxLevel = 0; |
| | | |
| | | /// <summary> |
| | | /// 默认最大级别 |
| | | /// 地形最大级别 |
| | | /// </summary> |
| | | public static int DEFAULT_MAX_LEVEL = 16; |
| | | public static int TERRAIN_MAX_LEVEL |
| | | { |
| | | get |
| | | { |
| | | if (0 == terrainMaxLevel) |
| | | { |
| | | string str = Tools.GetSetting("terrainMaxLevel"); |
| | | if (!int.TryParse(str, out terrainMaxLevel)) |
| | | { |
| | | terrainMaxLevel = 14; |
| | | } |
| | | } |
| | | |
| | | return terrainMaxLevel; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 默认最大文件大小:5GB |
| | | /// </summary> |
| | | public static long DDEFAULT_MAX_SIZE = 5L * 1024 * 1024 * 1024; |
| | | public static long DEFAULT_MAX_SIZE = 5L * 1024 * 1024 * 1024; |
| | | |
| | | /// <summary> |
| | | /// 获取Python文件 |
| | |
| | | /// </summary> |
| | | public static string GetReleaseUrl(string dircode) |
| | | { |
| | | return "http://{host}/LFData/3d/terrain/" + dircode; |
| | | return "{host}/LFData/3d/terrain/" + dircode; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | try |
| | | { |
| | | List<SysMeta> metas = XYZUtils.SelectMetas(args.ids, "and type in ('tif', 'tiff')"); |
| | | if (null == metas || metas.Count == 0) return null; |
| | | if (null == metas || metas.Count == 0) |
| | | { |
| | | LogOut.Info("TerraUtils:找不到元数据。"); |
| | | return null; |
| | | } |
| | | |
| | | string dirPath = GetTerrainPath(args.dircode); |
| | | //if (Directory.Exists(dirPath)) Tools.DelPath(dirPath); // 已存在的,删除 |
| | | |
| | | tifFile = Merge(metas, args, ref err); |
| | | if (!File.Exists(tifFile)) return null; |
| | | if (!File.Exists(tifFile)) |
| | | { |
| | | LogOut.Info("TerraUtils:找不到tifFile数据。"); |
| | | return null; |
| | | } |
| | | |
| | | string json = Path.Combine(dirPath, "layer.json"); |
| | | if (File.Exists(json)) File.Delete(json); |
| | | //Generate(args, tifFile, ref err); |
| | | CreateTerrain(args, tifFile, ref err); |
| | | |
| | | if (!File.Exists(json)) return null; |
| | | if (!File.Exists(json)) |
| | | { |
| | | LogOut.Info("TerraUtils:找不到layer.json文件。"); |
| | | return null; |
| | | } |
| | | Complement(args); |
| | | |
| | | List<int> ids = new List<int>(); |
| | |
| | | } |
| | | else |
| | | { |
| | | if (File.Exists(tifFile)) File.Delete(tifFile); |
| | | //if (File.Exists(tifFile)) File.Delete(tifFile); |
| | | WriteText(txtFile, metas, null); |
| | | if (File.Exists(tifFile)) return tifFile; |
| | | } |
| | | |
| | | string cmd = string.Format("python \"{0}\" -qgz {1} -file \"{2}\" -out \"{3}\"", PyFile, Qgz, txtFile, tifFile); |
| | | SysTask task = TaskDBHelper.CreateTask(args, "DEM", "高程镶嵌(DEM)"); |
| | | err = Tools.ExecCmd(task, cmd, true); |
| | | if (null == task || task.status != 2) return string.Empty; |
| | | |
| | | task = TaskDBHelper.SelectById(task.id); |
| | | if (null == task || task.status != 2) LogOut.Info("TerraUtils:任务为空或状态不为2。"); |
| | | |
| | | return tifFile; |
| | | } |
| | |
| | | private static int GetTerrainMaxLevel(XYZArgs args, string tifFile) |
| | | { |
| | | FileInfo fi = new FileInfo(tifFile); |
| | | if (fi.Length > DDEFAULT_MAX_SIZE) return DEFAULT_MAX_LEVEL; |
| | | if (fi.Length > DEFAULT_MAX_SIZE) return TERRAIN_MAX_LEVEL; |
| | | |
| | | string ctbPath = Tools.GetSetting("ctbPath"); |
| | | string dirPath = GetTerrainPath(args.dircode); |
| | |
| | | Tools.ExecCmd(new List<string>() { gdal_data, createLayer }); |
| | | |
| | | string layerJson = Path.Combine(dirPath, "layer.json"); |
| | | if (!File.Exists(layerJson)) return DEFAULT_MAX_LEVEL; |
| | | if (!File.Exists(layerJson)) return TERRAIN_MAX_LEVEL; |
| | | |
| | | string[] lines = File.ReadAllLines(layerJson, Encoding.UTF8); |
| | | |
| | |
| | | } |
| | | if (File.Exists(layerJson)) File.Delete(layerJson); |
| | | |
| | | return level > DEFAULT_MAX_LEVEL ? DEFAULT_MAX_LEVEL : level; |
| | | return level > TERRAIN_MAX_LEVEL ? TERRAIN_MAX_LEVEL : level; |
| | | } |
| | | |
| | | /// <summary> |