using ExportMap.db;
|
using ExportMap.Models;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.IO;
|
using System.Linq;
|
using System.Web;
|
|
namespace ExportMap.cs
|
{
|
public class XYZUtils
|
{
|
|
private static string pyFile;
|
|
/// <summary>
|
/// 获取Python文件
|
/// </summary>
|
public static string PyFile
|
{
|
get
|
{
|
if (string.IsNullOrWhiteSpace(pyFile))
|
{
|
pyFile = Path.Combine(ExportUtil.SourcesPath, "xyz.py");
|
}
|
|
return pyFile;
|
}
|
}
|
|
/// <summary>
|
/// QGIS工程
|
/// </summary>
|
public static string Qgz
|
{
|
get
|
{
|
return "xyz.qgz";
|
}
|
}
|
|
/// <summary>
|
/// 生成
|
/// </summary>
|
/// <param name="args">XYZ参数</param>
|
/// <param name="err">错误信息</param>
|
/// <returns>数据发布ID</returns>
|
public static int Generate(XYZArgs args, ref string err)
|
{
|
string tifFile = Path.Combine(ExportUtil.SourcesPath, ExportUtil.DateStr + ".txt");
|
string xyzPath = Path.Combine(SGUtils.LFData, "2d\\tiles", args.id.ToString());
|
if (!Directory.Exists(xyzPath)) Directory.CreateDirectory(xyzPath);
|
|
string cmd = string.Format("python {0} -qgz {1} -file {2} -out {3} -min {4} -max {5}", PyFile, Qgz, tifFile, xyzPath, args.min, args.max);
|
err = Tool.ExecCmd(cmd, true);
|
|
return args.id;
|
}
|
|
/// <summary>
|
/// 查询元数据
|
/// </summary>
|
private static List<SysMeta> selectMetas(string dircode)
|
{
|
string sql = string.Format("select * from lf.sys_meta where dircode like '{0}%'", dircode);
|
|
DataTable dt = Tool.DBHelper.GetDataTable(sql);
|
List<SysMeta> list = ModelHandler.FillModel<SysMeta>(dt);
|
|
return list;
|
}
|
|
/// <summary>
|
/// 查询元数据
|
/// </summary>
|
private static List<SysMeta> selectMetas(List<int> ids)
|
{
|
string sql = string.Format("select * from lf.sys_meta where id in ({0})", string.Join(",", ids));
|
DataTable dt = Tool.DBHelper.GetDataTable(sql);
|
List<SysMeta> list = ModelHandler.FillModel<SysMeta>(dt);
|
|
return list;
|
}
|
|
|
}
|
}
|