zoukankan      html  css  js  c++  java
  • 删除面积为1500以下的要素

    private void 处理面积ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                 pLayer = axMapControl2.get_Layer(0);
                 pFLayer = pLayer as IFeatureLayer;
                 pFC = pFLayer.FeatureClass;
    
                IFeatureCursor pFCursor = pFC.Search(null, false);
                IFeature pFeature = pFCursor.NextFeature();
    
    
                //创建表,获得要素ID,标识码,面积,用于筛选相同表示码,面积较小的要素
                DataTable pTable = new DataTable();
    
                DataColumn colID = new DataColumn("要素ID");
                colID.DataType = System.Type.GetType("System.String");
                pTable.Columns.Add(colID);
    
                DataColumn colIdent = new DataColumn("标识码");
                colIdent.DataType = System.Type.GetType("System.String");
                pTable.Columns.Add(colIdent);
    
                DataColumn colArea = new DataColumn("面积");
                colArea.DataType = System.Type.GetType("System.Double");
                
                pTable.Columns.Add(colArea);
    
                int indexOfFID_HBTC_Z = pFC.FindField("FID_HBTC_Z");
                int indexOfBSM = pFC.FindField("BSM");
                int indexOfTBMJ = pFC.FindField("TBMJ");
    
                while (pFeature != null)
                {
                    string FID_HBTC_Z = pFeature.get_Value(indexOfFID_HBTC_Z).ToString();
                    string BSM = pFeature.get_Value(indexOfBSM).ToString();
                    double TBMJ = (double)pFeature.get_Value(indexOfTBMJ);
    
                    DataRow pRow = pTable.NewRow();
                    pRow[0] = FID_HBTC_Z;
                    pRow[1] = BSM;
                    pRow[2] = TBMJ;
                    pTable.Rows.Add(pRow);
                    pFeature = pFCursor.NextFeature();
                }
    
                //从表中获得同一标识码的列表,并删除与当前标识码面积小的要素
    
                for (int i = 0; i < pTable.Rows.Count; i++)
                {
                    string bsm1 = pTable.Rows[i][1].ToString();
    
                    double TBMJ1 = (double)pTable.Rows[i][2];
    
                    for (int x = 0; x < pTable.Rows.Count; x++)
                    {
                        string FID_HBTC_Z2 = pTable.Rows[x][0].ToString();
                        string bsm2 = pTable.Rows[x][1].ToString();
                         double TBMJ2 = (double)pTable.Rows[x][2];
                        if (bsm1 == bsm2)
                        {
                            if (TBMJ1 > TBMJ2)
                            {
                                deleteFeature(FID_HBTC_Z2);
                            }
                        }
                    }
                    
    
                }
    
    
                //dataGridView1.DataSource = pTable;
            }
    
            
            private void deleteFeature(string FID_HBTC_Z)
            {
    
                IQueryFilter queryFilter = new QueryFilterClass();
                queryFilter.WhereClause = "FID_HBTC_Z=" + FID_HBTC_Z;
    
    
                IFeatureCursor updateCursor = pFC.Update(queryFilter, true);
    
                IFeature feature1 = updateCursor.NextFeature();
    
               
    
                while (feature1 != null)
                {
                    updateCursor.DeleteFeature();
                    
    
    
                    feature1 = updateCursor.NextFeature();
    
                }
    
                updateCursor.Flush();
    
                //TokayWorkspace.ComRelease(del_featcur);
                //updateCursor = null;  
    
    
    
                axMapControl2.ActiveView.Refresh();
            }
    
  • 相关阅读:
    ural 1110,快速幂
    ural 1109,NYOJ 239,匈牙利算法邻接表
    CodeBlocks养眼的colour theme
    UVa 10047,独轮车
    UVa 10054,欧拉回路
    UVa 11624,两次BFS
    hiho一下,第115周,FF,EK,DINIC
    Poj(1220),hash
    2013 Asia Regional Changchun I 题,HDU(4821),Hash
    UVa 213,World Finals 1991,信息解码
  • 原文地址:https://www.cnblogs.com/xianerwonder/p/4239005.html
Copyright © 2011-2022 走看看