dotspatial mysql_Dotspatial 要素重叠分析

private void toolStripButton30_Click(object sender, EventArgs e)

{

//面状重叠分析

if (mapMain.Layers.Count == 0)

{

return;

}

//重叠分析

//遍历要素,显示面积

FeatureSet fs = null;

fs = Lzq_LayerManager.getFeatureSetByName(layerNamePolygon, mapMain); //(FeatureSet) map1.Layers[0].DataSet;

//MessageBox.Show("图层类型:" + fs.FeatureType.ToString());

if (fs.FeatureType != FeatureType.Polygon)

{

return;

}

DotSpatial.Topology.Geometry gm1, gm2;

for (int i = 0; i < fs.Features.Count; i++)

{

gm1 = (DotSpatial.Topology.Geometry) (fs.Features[i].BasicGeometry);

for (int j = i + 1; j < fs.Features.Count; j++)

{

gm2 = (DotSpatial.Topology.Geometry) (fs.Features[j].BasicGeometry);

if (gm1.IsSimple && gm2.IsSimple)

{

try

{

if (gm1.Overlaps(gm2)) //重叠

{

//try

//{

Geometry p = (Geometry)gm1.Intersection(gm2);

DotSpatial.Topology.CoordinateArrays.RemoveRepeatedPoints(p.Coordinates);

if (p.Area > 0.001)

{

MessageBox.Show("\ngm1——lb:" +

fs.Features[i].DataRow["林班号"].ToString() + " xb:" +

fs.Features[i].DataRow["小班号"].ToString() + "——gm1 Area" +

gm1.Area.ToString() +

"\ngm2——lb:" +

fs.Features[j].DataRow["林班号"].ToString() + " xb:" +

fs.Features[j].DataRow["小班号"].ToString() + "——gm2 Area" +

gm2.Area.ToString() +

"\n重叠 面积:" +

p.Area);

}

//}

//catch

//{

//}

}

}

catch

{

}

}

//}

//catch (Exception exc)

//{

// // MessageBox.Show(exc.Message);

//}

}

}

fs = null;

}

7419dad71e1aec4e65e0c87a67b6dbc1.gif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值