zoukankan      html  css  js  c++  java
  • 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);
    }

  • 相关阅读:
    2020春软件工程助教工作总结 第三周
    Zend Framework MVC的结构
    Zend_Cache的使用
    小油2018 win7旗舰版64位GHOST版的,安装telnet客户端时,提示:出现错误。并非所有的功能被成功更改。
    redis常用配置参数详解
    CentOS 7 源码编译安装 Redis
    Linux(CentOS)下设置nginx开机自动启动(2个办法)
    CST,CET,UTC,GMT,DST,Unix时间戳几种常见时间概述与关系(转)
    PHP_OS的常见值
    PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别
  • 原文地址:https://www.cnblogs.com/kogame/p/10017464.html
Copyright © 2011-2022 走看看