• Dotspatial 空间要素选择


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

    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();
    }

  • 相关阅读:
    官方文档翻译-Today
    RAC & MVVM 学习资料整理
    35种常用字体
    中文字体的种类
    自言自语(三)--部分中文字体
    自言自语(二)--英文无衬线体和有衬线体
    sketch字体设置技巧(一)---通过锚点改变字体形态
    提高设计档次的8个方法
    知识汇总09~bootstrap-select在Vue中的封装
    知识汇总08~字符串截取
  • 原文地址:https://www.cnblogs.com/kogame/p/6536455.html
Copyright © 2020-2023  润新知