本文整理汇总了C#中DotSpatial.Data.FeatureSet.AddFid方法的典型用法代码示例。如果您正苦于以下问题:C# FeatureSet.AddFid方法的具体用法?C# FeatureSet.AddFid怎么用?C# FeatureSet.AddFid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotSpatial.Data.FeatureSet
的用法示例。
在下文中一共展示了FeatureSet.AddFid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: exportSDFtoShapeFile
public static void exportSDFtoShapeFile(string inputsdfFile, string outputShapefile)
{
using (TextReader reader = new StreamReader(inputsdfFile))
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.Trim() == "BEGIN BOUNDS:")
{
FeatureSet fs = new FeatureSet(FeatureType.Polygon);
fs.DataTable.Columns.AddRange(new DataColumn[]
{
new DataColumn("ProfileName" , typeof(string)),
new DataColumn("ProfileDate" , typeof(string)),
});
fs.AddFid();
while ((line = reader.ReadLine()) != null)
{
if (line.Trim() == "END BOUNDS:")
{
fs.SaveAs(outputShapefile, true);
break;
}
else if (line.Trim() == "PROFILE LIMITS:")
{
string profileName = "";
bool isDate = false;
DateTime dateTime = DateTime.Now;
IList<Coordinate> coordinates = new List<Coordinate>();
while ((line = reader.ReadLine()) != null)
{
string[] cols;
double x, y, z;
if (line.Trim() == "END:")
{
Polygon p = new Polygon(coordinates);
IFeature f = fs.AddFeature(p);
f.DataRow.BeginEdit();
f.DataRow["ProfileName"] = profileName;
if (isDate)
{
f.DataRow["ProfileDate"] = dateTime.ToString("yyyy/MM/dd HH:mm:ss");
}
f.DataRow.EndEdit();
break;
}
else if (line.Trim() == "POLYGON:")
{
}
else if ((cols = line.Trim().Split(new string[] { ":", "," }, StringSplitOptions.RemoveEmptyEntries)).Length > 1)
{
if (cols[0].Trim() == "PROFILE ID")
{
profileName = cols[1].Trim();
cols = profileName.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
int day, year;
if (cols.Length == 2 && int.TryParse(cols[0].Substring(0, 2), out day) && int.TryParse(cols[0].Substring(5, 4), out year) && months.ContainsKey(cols[0].Substring(2, 3)))
{
isDate = true;
dateTime = new DateTime(year, months[cols[0].Substring(2, 3)], day);
dateTime = dateTime.AddHours(double.Parse(cols[1].Substring(0, 2)));
dateTime = dateTime.AddMinutes(double.Parse(cols[1].Substring(2, 2)));
}
}
else if (
double.TryParse(cols[0], out x) &&
double.TryParse(cols[1], out y) &&
double.TryParse(cols[2], out z)
)
{
coordinates.Add(new Coordinate(x, y, z) { Z = z });
}
}
}
}
}
}
}
}
//.........这里部分代码省略.........