?最近在做 通过shp 文件生成图形地块的任务
地块颜色需要符合标准? 于是就写了这个
csv 文件地址? 程序可以自动识别
https://download.csdn.net/download/po123op123/83780807
public class ColorBlockStandard
{
/// <summary>
/// 类别代码
/// </summary>
public string CategoryCode { get; set; }
/// <summary>
/// 类别名称
/// </summary>
public string CategoryName { get; set; }
/// <summary>
/// 颜色代码
/// </summary>
public int ColorCode { get; set; }
public string RGB { get; set; }
}
List<ColorBlockStandard> LCBS = new List<ColorBlockStandard>();
/// <summary>
/// 初始化 城市与城乡规划用地分类和色块标准
/// </summary>
void InitColorBlockStandard()
{
string path = @"城市与城乡规划用地分类和色块标准-90版-2011版 - 副本.csv";
if (!File.Exists(path))
return;
var lines = File.ReadAllLines(path, Encoding.Default);
for (int i = 1; i < lines.Count(); i++)
{
var tmp = lines[i].Split(',');
// 解决 RGB字段中引号逗号问题
// 取出处理3,4,5 赋值3 删除4,5
tmp[3] = tmp[3].Substring(1) + "," + tmp[4] + "," + tmp[5].Substring(0, tmp[5].Length - 1);
LCBS.Add(new ColorBlockStandard
{
CategoryCode = tmp[0],
CategoryName = tmp[1],
ColorCode = Convert.ToInt32(tmp[2]),
RGB = tmp[3]
}
);
}
}
获取
foreach (var item in LCBS)
{
if (item.CategoryCode == YDDM)
{
outcolor = item.RGB;
break;
}
}
|