Dotspatial 要素重叠部分去除
Posted kogame
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dotspatial 要素重叠部分去除相关的知识,希望对你有一定的参考价值。
private void toolStripButton32_Click(object sender, EventArgs e)
{
/重叠部分去除操作——测试成功
if (mapMain.Layers.Count == 0)
{
return;
}
//重叠分析
//遍历要素,显示面积
FeatureSet fs = null;
fs = Lzq_LayerManager.getFeatureSetByName(layerNamePolygon, mapMain);
if (fs.FeatureType != FeatureType.Polygon)
{
return;
}
for (int i = 0; i < fs.Features.Count; i++)
{
var gm1 = (DotSpatial.Topology.Geometry) (fs.Features[i].BasicGeometry); // point
//DotSpatial.Topology.CoordinateArrays.RemoveRepeatedPoints(gm1.Coordinates);
for (int j = i + 1; j < fs.Features.Count ; j++)
{
var gm2 = (DotSpatial.Topology.Geometry) (fs.Features[j].BasicGeometry);
if (gm1.IsSimple && gm2.IsSimple)
{
//try
//{
if (gm1.Overlaps(gm2))
{
IGeometry geo = (gm1.Difference(gm2));
DotSpatial.Topology.CoordinateArrays.RemoveRepeatedPoints(geo.Coordinates);
if (geo.IsSimple)
{
geo.Normalize();
fs.Features[i].BasicGeometry = geo;
}
}
//}
//catch(Exception exc)
//{
// string msg = "林班号:" + fs.Features[i].DataRow["林班号"].ToString() +
// " 小班号:" + fs.Features[i].DataRow["小班号"].ToString();
// MessageBox.Show(exc + "
" + msg);
//}
}
else
{
MessageBox.Show("isSimple is false");
}
}
}
MessageBox.Show("图斑个数:"+fs.Features.Count.ToString()+"
属性表个数:"+fs.DataTable.Rows.Count);
fs.UpdateExtent();
fs.InitializeVertices();
fs.Save();
mapMain.ResetBuffer();
MessageBox.Show(@"重叠去除功能,执行完毕!", @"系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
以上是关于Dotspatial 要素重叠部分去除的主要内容,如果未能解决你的问题,请参考以下文章