using ExportMap.Models;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
|
namespace ExportMap.cs
|
{
|
public class TerrainUtils
|
{
|
private static int terrainMaxLevel = 0;
|
|
/// <summary>
|
/// 地形最大级别
|
/// </summary>
|
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>
|
/// 重投影
|
/// </summary>
|
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);
|
|
Tools.ExecCmd(new List<string> { cmd });
|
}
|
|
/// <summary>
|
/// 指定投影
|
/// </summary>
|
public static void Project(string sourceFile, string targetSrs)
|
{
|
List<string> list = new List<string>();
|
list.Add("cd \"C:\\Program Files\\QGIS 3.16\\apps\\Python37\"");
|
//list.Add("set GDAL_DATA=\"C:\\Program Files\\QGIS 3.16\\share\\gdal\"");
|
//list.Add("set PROJ_LIB=\"C:\\Program Files\\QGIS 3.16\\share\\proj\"");
|
list.Add("\"C:\\Program Files\\QGIS 3.16\\bin\\qgis_process-qgis-ltr.bat\"");
|
|
string cmd = string.Format("python \"C:\\Program Files\\QGIS 3.16\\apps\\Python37\\Scripts\\gdal_edit.py\" -a_srs {0} {1}", targetSrs, sourceFile);
|
list.Add(cmd);
|
|
string rs = "";
|
string err = Tools.ExecCmd(new List<string> { cmd }, ref rs);
|
}
|
}
|
}
|