首页 > 其他 > 详细

Dotspatial 空间要素选择

时间:2017-03-11 23:47:28      阅读:913      评论:0      收藏:0      [点我收藏+]

//通过遍历选择要素,获取选择要素相交的要素

private void toolStripButton43_Click(object sender, EventArgs e)

{

//查看与选中要素重叠的要素
if (map1.Layers.Count == 0)
{
return;
}
//重叠分析
//遍历要素,显示面积
PolygonLayer pLayer = map1.Layers[0] as PolygonLayer;
FeatureSet fs = null;
fs = (FeatureSet) map1.Layers[0].DataSet;
if (pLayer.Selection.Count == 0)
{
MessageBox.Show("无选中记录", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

// //遍历选择要素
foreach (Feature feature in pLayer.Selection.ToFeatureList())
{
////实现方式1==================
IEnvelope pEnvelope = null;
pLayer.Select(null, feature.Envelope, SelectionMode.Intersects, out pEnvelope);

////实现方式2=================

//FeatureSet pPolygonFeatureSet = new FeatureSet(DotSpatial.Topology.FeatureType.Polygon);
////pPolygonFeatureSet.Projection = KnownCoordinateSystems.Geographic.World.WGS1984;
//pPolygonFeatureSet.AddFeature(feature);

//Extent pAffectedExtent = null;

//var result = fs.Select(pPolygonFeatureSet.Extent);//, out pAffectedExtent,

//foreach (IFeature feature2 in result)
//{
// pLayer.ZoomToSelectedFeatures();
// MessageBox.Show(feature.DataRow["林班号"] + "-" + feature.DataRow["小班号"] + "重叠:" + feature2.DataRow["林班号"] + "-" + feature2.DataRow["小班号"]); //feature2.DataRow.Field<Int64>("林班号").ToString()
//}

//实现方式3
//var gm1 = (DotSpatial.Topology.Geometry)(feature.BasicGeometry);// point
//foreach (IFeature feature2 in fs.Features)
//{
// //MessageBox.Show(feature.DataRow.Field<string>("NAME"));
// var gm2 = (DotSpatial.Topology.Geometry)(feature2.BasicGeometry);
// if (gm2.Overlaps(gm1))
// {
// MessageBox.Show(feature.DataRow["林班号"] + "-" + feature.DataRow["小班号"] + "重叠:" + feature2.DataRow["林班号"] + "-" + feature2.DataRow["小班号"]);

// // code for whatever you want to do
// }
//}
//======================

}
pLayer.ZoomToSelectedFeatures();
}

Dotspatial 空间要素选择

原文:http://www.cnblogs.com/kogame/p/6536455.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!