| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 转换地形 |
| | | /// </summary> |
| | | [HttpPost] |
| | | public ResponseMsg<string> ToTerrain([FromBody]XYZArgs args) |
| | | { |
| | | try |
| | | { |
| | | ResponseMsg<string> msg = checkArgs(args, true); |
| | | if (null != msg) return msg; |
| | | |
| | | checkMinMax(args); |
| | | |
| | | string err = null; |
| | | List<int> rs = TerrainUtils.Generate(args, ref err); |
| | | if (null == rs || rs.Count == 0) |
| | | { |
| | | return ResponseMsg<string>.fail(null == err ? "失败" : err); |
| | | } |
| | | |
| | | return ResponseMsg<string>.success("成功", string.Join(",", rs), rs.Count); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); |
| | | return ResponseMsg<string>.fail(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 转换LAS |
| | | /// </summary> |
| | | [HttpPost] |
| | |
| | | <add key="sgDB" value="D:\LF\SG\catalog.db"/> |
| | | <!-- cesium-terrain-builder路径 --> |
| | | <add key="ctbPath" value="E:\WebSite\Cesium\Tool\ctb-0.41" /> |
| | | <!-- CTB-JL版本 --> |
| | | <add key="ctbJL" value="E:\WebSite\Cesium\Tool\ctb_jl"/> |
| | | <!-- 3dtiles路径 --> |
| | | <add key="d3tilesPath" value="E:\WebSite\Cesium\Tool\3dtiles" /> |
| | | <!-- gocesiumtiler路径 --> |
| | |
| | | { |
| | | try |
| | | { |
| | | List<SysMeta> metas = XYZUtils.SelectMetas(args.ids, "and type in ('tif', 'tiff')"); |
| | | List<SysMeta> metas = XYZUtils.SelectMetas(args.ids, "and type in ('tif', 'tiff', 'dem')"); |
| | | if (null == metas || metas.Count == 0) return PrintInfo("找不到元数据"); |
| | | |
| | | string dirPath = GetTerrainPath(args.dircode); |
| | |
| | | /// </summary> |
| | | private static void CreateTerrain(XYZArgs args, string tifFile, ref string err) |
| | | { |
| | | string ctbPath = Tools.GetSetting("ctbPath"); |
| | | string ctbPath = Tools.GetSetting("ctbJL"); |
| | | string dirPath = GetTerrainPath(args.dircode); |
| | | int maxLevel = GetTerrainMaxLevel(args, tifFile); |
| | | //int maxLevel = GetTerrainMaxLevel(args, tifFile); |
| | | |
| | | string gdal_data = string.Format("set GDAL_DATA={0}\\data", ctbPath); |
| | | // -N 顶点法线, -C 强制创建缺失根瓦片, -R 不覆盖现有文件 |
| | | string createMesh = string.Format("{0}\\ctb-tile.exe -R -C -s {4} -o \"{1}\" -f Mesh \"{2}\\{3}.tif\"", ctbPath, dirPath, dirPath, args.dircode, maxLevel); |
| | | //string createLayer = string.Format("{0}\\ctb-tile.exe -l -s {4} -o \"{1}\" -f Mesh \"{2}\\{3}.tif\"", ctbPath, dirPath, dirPath, args.dircode, maxLevel); |
| | | // -N 顶点法线, -C 强制创建缺失根瓦片, -R 不覆盖现有文件,-f Mesh |
| | | string createMesh = string.Format("{0}\\ctb-tile.exe -s {1} -o \"{2}\" \"{3}\"", ctbPath, TERRAIN_MAX_LEVEL, dirPath, tifFile); |
| | | |
| | | List<string> list = new List<string>() { gdal_data, createMesh }; |
| | | SysTask task = TaskDBHelper.CreateTask(args, "DEM", "高程数据(DEM)"); |
| | |
| | | CreateVrt(files, vrt); |
| | | if (!File.Exists(vrt)) return null; |
| | | |
| | | string ctbPath = Tools.GetSetting("ctbPath"); |
| | | string ctbPath = Tools.GetSetting("ctbJL"); |
| | | string gdal_data = string.Format("set GDAL_DATA={0}\\data", ctbPath); |
| | | string createLayer = string.Format("{0}\\ctb-tile.exe -l -o \"{1}\" -f Mesh \"{2}\"", ctbPath, dirPath, vrt); |
| | | string createLayer = string.Format("{0}\\ctb-tile.exe -l -s {1} -o \"{2}\" \"{3}\"", ctbPath, TERRAIN_MAX_LEVEL, dirPath, vrt); |
| | | Tools.ExecCmd(new List<string>() { gdal_data, createLayer }); |
| | | |
| | | return vrt; |
| | |
| | | FileInfo fi = new FileInfo(tifFile); |
| | | if (fi.Length > DEFAULT_MAX_SIZE) return TERRAIN_MAX_LEVEL; |
| | | |
| | | string ctbPath = Tools.GetSetting("ctbPath"); |
| | | string ctbPath = Tools.GetSetting("ctbJL"); |
| | | string dirPath = GetTerrainPath(args.dircode); |
| | | string subPath = Path.Combine(dirPath, "subs"); |
| | | |
| | | string gdal_data = string.Format("set GDAL_DATA={0}\\data", ctbPath); |
| | | string createLayer = string.Format("{0}\\ctb-tile.exe -l -o \"{1}\" -f Mesh \"{2}\\{3}.tif\"", ctbPath, dirPath, dirPath, args.dircode); |
| | | string createLayer = string.Format("{0}\\ctb-tile.exe -l -o \"{1}\" \"{2}\"", ctbPath, subPath, tifFile); |
| | | |
| | | Tools.ExecCmd(new List<string>() { gdal_data, createLayer }); |
| | | |
| | | string layerJson = Path.Combine(dirPath, "layer.json"); |
| | | string layerJson = Path.Combine(subPath, "layer.json"); |
| | | if (!File.Exists(layerJson)) return TERRAIN_MAX_LEVEL; |
| | | |
| | | string[] lines = File.ReadAllLines(layerJson, Encoding.UTF8); |
| | |
| | | public static void Reproject(string sourceFile, string targetFile, string sourceSrs, string targetSrs) |
| | | { |
| | | string gdalPath = Tools.GetSetting("gdalPath"); |
| | | string cmd = string.Format("{0}\\gdalwarp.exe -s_srs {1} -t_srs {2} -r near -of GTiff {3} {4}", gdalPath, sourceSrs, targetSrs, sourceFile, targetFile); |
| | | string cmd = string.Format("\"{0}\\gdalwarp.exe\" -s_srs {1} -t_srs {2} -r near -of GTiff \"{3}\" \"{4}\"", gdalPath, sourceSrs, targetSrs, sourceFile, targetFile); |
| | | |
| | | Tools.ExecCmd(new List<string> { cmd }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 指定投影 |
| | | /// 指定投影 * |
| | | /// </summary> |
| | | public static void Project(string sourceFile, string targetSrs) |
| | | { |
| | |
| | | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| | | <script src="js/jquery.1.12.4.js"></script> |
| | | <script> |
| | | var token = "384d7382-ea48-400b-bc92-58cb2b28bcbc"; |
| | | var token = "0b8d4418-d7bd-4846-ba45-edccf42e87c3"; |
| | | |
| | | $(function () { |
| | | $("#token").html(token); |
| | |
| | | }); |
| | | } |
| | | |
| | | // 测试Terra:10526,10527 |
| | | // 测试Terra:10526,10527 | 10531 |
| | | function toTerra() { |
| | | var data = { token: token, ids: [10531], min: 0, max: 18, depcode: "00", dircode: "090000", userId: 1, name: "中缅" }; |
| | | ajax("Convert/ToTerra", "POST", JSON.stringify(data), null, null, function (rs) { |
| | | var data = { token: token, ids: [1413, 1412], min: 0, max: 18, depcode: "00", dircode: "0B", userId: 1, name: "川二" }; |
| | | ajax("Convert/ToTerrain", "POST", JSON.stringify(data), null, null, function (rs) { |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | console.log(rs); |
| | | }); |