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

  • 相关阅读:
    使用HttpClient短信网关接口实现手机号验证码注册
    Linux安装nginx、redis(在线安装)
    Linux安装Tomcat(本地安装)
    Linux搭建java运行环境(本地安装)
    Linux的安装注意事项
    Linux的Shell常用命令
    applicationContext.xml的复用(import resource)
    Redis解决Session共享问题(如果开启nginx,实现负载均衡)
    Redis缓存商品查询信息(SpringMVC)
    Spring整合Redis
  • 原文地址:https://www.cnblogs.com/kogame/p/10017464.html
Copyright © 2020-2023  润新知