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

  • 相关阅读:
    Dos命令快速设置ip、网关、dns地址
    远程桌面连接保存登陆用户以及密码(凭据)备份方法
    如何启用windows8, windows10中被停用的远程桌面,如何连接windows10远程桌面?
    通过日志恢复SQL Server的历史数据
    http://sourceforge.net/projects/rtspdirectshow/
    iphone上实现H264 硬编码
    利用lipo编译合并iPhone模拟器和真机通用的静态类
    在iOS上使用ffmpeg播放视频
    基于.Net的单点登录(SSO)解决方案
    java实现简单的单点登录
  • 原文地址:https://www.cnblogs.com/kogame/p/10017464.html
Copyright © 2011-2022 走看看