private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         IFeatureClass pFeatureClassSave = pFeatureLayerEmergency.FeatureClass;
         IQueryFilter  pQueryFilterSave  = new QueryFilterClass();
         pQueryFilterSave.WhereClause = "FID=" + Convert.ToString(Convert.ToInt32(comboBox2.Text) - 1);
         IFeatureCursor pFeatureCursorSave = pFeatureClassSave.Update(pQueryFilterSave, false);
         IFeature       pFeatureSave       = pFeatureCursorSave.NextFeature();
         int            number             = Convert.ToInt32(textBox7.Text);
         int[]          EmergencyResource  = new int[number];
         EmergencyResource[0] = pFeatureCursorSave.FindField(comboBox3.Text.ToString());
         for (int i = 1; i < number; i++)
         {
             EmergencyResource[i] = pFeatureCursorSave.FindField(combobox[i - 1].Text.ToString());
         }
         while (pFeatureSave != null)
         {
             pFeatureSave.set_Value(EmergencyResource[0], double.Parse(textBox1.Text));
             for (int j = 1; j < number; j++)
             {
                 pFeatureSave.set_Value(EmergencyResource[j], double.Parse(textbox[j - 1].Text));
             }
             pFeatureCursorSave.UpdateFeature(pFeatureSave);
             pFeatureSave = pFeatureCursorSave.NextFeature();
         }
         MessageBox.Show("保存完成!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.Message.ToString(), "异常");
     }
 }
示例#2
0
        private void createAndFillPlotsTable()
        {
            //DataTable dTblPlots = dSet.Tables.Add("Table", "tblPlots");
            //dTblPlots.Columns.Add("PLT_CN",System.Type.GetType("System.String"));
            IQueryFilter qf = new QueryFilterClass();

            qf.SubFields = PlotCnField;
            if (SubPlotField != "" && SubPlotField != null)
            {
                qf.SubFields = PlotCnField + "," + SubPlotField;
            }
            IFeatureCursor fCur     = SampleFeatureClass.Search(qf, true);
            int            cnIndex  = fCur.FindField(PlotCnField);
            int            subIndex = fCur.FindField(SubPlotField);
            IFeature       ftr      = fCur.NextFeature();

            while (ftr != null)
            {
                string plCn   = ftr.get_Value(cnIndex).ToString();
                string subPlt = "0";
                if (subIndex > -1)
                {
                    object subPltObj = ftr.get_Value(subIndex);
                    if (subPltObj != null)
                    {
                        subPlt = subPltObj.ToString();
                    }
                }
                string pltID = plCn + "_" + subPlt;
                //Console.WriteLine(pltID);
                unPlots.Add(pltID);
                ftr = fCur.NextFeature();
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(fCur);
        }
示例#3
0
        public static string GetMaxValue(IFeatureClass featureClass, string fieldName)
        {
            List <string> list        = new List <string>();
            IQueryFilter  queryFilter = new QueryFilterClass();

            queryFilter.SubFields = fieldName;
            IFeatureCursor featureCursor = featureClass.Search(queryFilter, false);
            int            idx           = featureCursor.FindField(fieldName);

            if (idx < 0)
            {
                return("");
            }
            IFeature feature;

            while ((feature = featureCursor.NextFeature()) != null)
            {
                if (feature.Value[idx] is DBNull || feature.Value[idx] == null)
                {
                    continue;
                }
                list.Add(feature.Value[idx].ToString());
            }
            Marshal.ReleaseComObject(featureCursor);
            return(list.Max());
        }
示例#4
0
        /// <summary>
        /// 获取唯一值
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetValue_Click(object sender, EventArgs e)
        {
            lbValue.Items.Clear();
            //将pWorkspace强转成要素工作空间
            IFeatureWorkspace pFtWorkspace = pWorkspace as IFeatureWorkspace;
            //通过要素工作空间打开cboSelectLayer选择的图层, 并放在要素类中
            IFeatureClass pFtClass = pFtWorkspace.OpenFeatureClass(cboSelectLayer.Text);
            //打开游标, null为查询全部, false表示游标到达最后一条要素以后不回收
            IFeatureCursor pFtCursor = pFtClass.Search(null, false);
            //声明一个pFt要素并将查询结果中的第一条Feature赋值给它
            IFeature pFt = pFtCursor.NextFeature();
            //声明index作为下标使用
            int index = 0;

            //将index赋值为找到选中字段下标
            index = pFtCursor.FindField(lbShow.Text);
            //当要素不为空时
            while (pFt != null)
            {
                //如果lbValue中包含要素下标则游标到下一个要素, 跳过本次循环
                if (lbValue.Items.Contains(pFt.get_Value(index)))
                {
                    pFt = pFtCursor.NextFeature();
                    continue;
                }
                //将游标的的要素加到lbValue中
                lbValue.Items.Add(pFt.get_Value(index));
                //转到下一个要素
                pFt = pFtCursor.NextFeature();
            }
        }
        /// <summary>
        /// Returns a list of feature integer values of the given ID field name or OID value.
        /// </summary>
        /// <param name="featureClass"></param>
        /// <param name="filter"></param>
        /// <param name="idFldName"></param>
        /// <returns></returns>
        public static IList <int> GetIDs(this IFeatureClass featureClass, string filter = null, string idFldName = null)
        {
            IList <int> ids = new List <int>();

            int            idFldIdx    = -1;
            IFeatureCursor newfeatures = featureClass.Search(filter);

            if (!string.IsNullOrWhiteSpace(idFldName) && (idFldIdx = newfeatures.FindField(idFldName)) > -1)
            {
                IFeature feature = null;
                while ((feature = newfeatures.NextFeature()) != null)
                {
                    ids.Add(Convert.ToInt32(feature.Value[idFldIdx]));
                }
            }
            else
            {
                IFeature feature = null;
                while ((feature = newfeatures.NextFeature()) != null)
                {
                    ids.Add(feature.OID);
                }
            }

            return(ids);
        }
示例#6
0
        private void adjustXTableFtr(IGeometry iGeometry)
        {
            string         clFldName = dgc.IndependentFieldNames[0];
            ISpatialFilter sf        = new SpatialFilterClass();

            sf.Geometry      = iGeometry;
            sf.GeometryField = ftrMap.ShapeFieldName;
            sf.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
            double         tN       = 0;
            IFeatureCursor ftrCur   = ftrMap.Search(sf, false);
            IFeature       ftr      = ftrCur.NextFeature();
            int            fldIndex = ftrCur.FindField(clFldName);

            while (ftr != null)
            {
                object vlObj = ftr.get_Value(fldIndex);
                if (vlObj == null)
                {
                }
                else
                {
                    string vl      = vlObj.ToString();
                    int    vlIndex = olabels.IndexOf(vl);
                    nCnts[vlIndex] = nCnts[vlIndex] + 1;
                    tN            += 1;
                }
                ftr = ftrCur.NextFeature();
            }
            updateXTable(tN);
        }
示例#7
0
 private void updateFldPlt()
 {
     if (pltFtc == null || cnFldName == null)
     {
         return;
     }
     else
     {
         IQueryFilter qf = new QueryFilterClass();
         qf.SubFields = cnFldName;
         IFeatureCursor ftrCur   = pltFtc.Search(qf, true);
         int            fldIndex = ftrCur.FindField(cnFldName);
         if (fldIndex > -1)
         {
             fieldPltCn.Clear();
             IFeature ftr = ftrCur.NextFeature();
             while (ftr != null)
             {
                 fieldPltCn.Add(ftr.get_Value(fldIndex).ToString().ToUpper());
                 ftr = ftrCur.NextFeature();
             }
             System.Runtime.InteropServices.Marshal.ReleaseComObject(ftrCur);
             updateSpeciesFromTreeTable();
         }
     }
 }
示例#8
0
 private int GetFieldIdx(IFeatureCursor cursor, string locatorNameField)
 {
     if (string.IsNullOrEmpty(locatorNameField))
     {
         return(-1);
     }
     return(cursor.FindField(locatorNameField));
 }
示例#9
0
        private bool updatePolygon(IFeatureClass ftrCls, int oid)
        {
            bool           x     = false;
            IGeometry      geo   = ftrCls.GetFeature(oid).ShapeCopy;
            ISpatialFilter spFlt = new SpatialFilterClass();

            spFlt.WhereClause = ftrCls.OIDFieldName + " <> " + oid.ToString();
            spFlt.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
            IQueryFilterDefinition2 qryDef2 = (IQueryFilterDefinition2)spFlt;

            qryDef2.PostfixClause = "Order by Shape_Area DESC";
            spFlt.Geometry        = geo;
            spFlt.GeometryField   = ftrCls.ShapeFieldName;
            spFlt.SearchOrder     = esriSearchOrder.esriSearchOrderSpatial;
            IFeatureCursor ftrCur         = ftrCls.Search(spFlt, false);
            int            shapeAreaIndex = ftrCur.FindField("Shape_Area");
            IFeature       ftr            = ftrCur.NextFeature();

            while (ftr != null)
            {
                IGeometry             geoMax    = ftr.ShapeCopy;
                int                   beforeCnt = ((IGeometryCollection)geoMax).GeometryCount;
                ITopologicalOperator4 tp        = (ITopologicalOperator4)geoMax;
                IGeometry             uGeo      = tp.Union(geo);
                int                   afterCnt  = ((IGeometryCollection)uGeo).GeometryCount;
                if (beforeCnt >= afterCnt)
                {
                    try
                    {
                        ftr.Shape = uGeo;
                        if (shapeAreaEdit)
                        {
                            ftr.set_Value(shapeAreaIndex, ((IArea)uGeo).Area);
                        }
                        ftr.Store();
                        x = true;
                        return(x);
                    }
                    catch (Exception e)
                    {
                        x = false;
                        Console.WriteLine(e.ToString());
                        return(x);
                    }
                }
                ftr = ftrCur.NextFeature();
            }
            return(x);
        }
示例#10
0
        //
        //		//Create a RasterValue from IRasterDataset
        //		//在此处应该设置影像数据的存储参数
        //		public IRasterValue createRasterValue(IRasterDataset pRasterDs)
        //		{
        //			IRasterValue pRasterVal;
        //			IRasterStorageDef pRasStoreDef;
        //
        //			// ++ set storage parameter
        //			pRasStoreDef = new RasterStorageDefClass();//createRasterStorageDef
        //
        //			pRasStoreDef.CompressionType = esriRasterSdeCompressionTypeEnum.esriRasterSdeCompressionTypeRunLength;
        //			pRasStoreDef.PyramidResampleType = rstResamplingTypes.RSP_CubicConvolution;
        //			pRasStoreDef.PyramidLevel = -1;
        //
        //			// ++ set raster value to raster field
        //			pRasterVal = new RasterValueClass();
        //			pRasterVal.RasterDataset = pRasterDs;
        //			pRasterVal.RasterStorageDef = pRasStoreDef;
        //
        //			return(pRasterVal);
        //
        //		}

        //Delete a Raster in RasterCatalog by it's name
        public void DelRasterInCatalog(IFeatureClass pCatalog, string RasterDSName)
        {
            //1.根据名称在featureClass 中找到feature
            IQueryFilter pQueryFilter = new QueryFilterClass();

            pQueryFilter.WhereClause = "NAME ='" + RasterDSName + "'";

            IFeatureCursor pFeatCur = pCatalog.Search(pQueryFilter, false);

            int i = pFeatCur.FindField("Name");

            IFeature pFeat = pFeatCur.NextFeature();

            pFeat.Delete();
        }
示例#11
0
        public IRasterDataset GetRasterDatasetInCatalog(IFeatureClass pCatalog, string RasterDSName)
        {
            //1.根据名称在featureClass 中找到feature
            IQueryFilter pQueryFilter = new QueryFilterClass();

            pQueryFilter.WhereClause = "NAME ='" + RasterDSName + "'";

            IFeatureCursor pFeatCur = pCatalog.Search(pQueryFilter, false);

            int i = pFeatCur.FindField("Name");

            IFeature pFeat = pFeatCur.NextFeature();

            //2.找到Raster字段,并把其中的值返回IRasterDataset
            IRasterCatalogItem pRasCatItem = pFeat as IRasterCatalogItem;

            return(pRasCatItem.RasterDataset);
        }
示例#12
0
        /// <summary>
        /// Runs the SAS logistic procedure must have a SampleLocations, OutWorkspace, DependentField, IndependentFields, ClassFields, and optionally Validate and Weight must be specified to run
        /// Running the procedure will create a series of files within the SAS output directory (Workspace path \\SASOUTPUT) These files include; prc.log, prc.sas, prc.lst, outest.csv, and another csv
        /// file of the sample data named after the sample location feature class. Prc.log is the SAS log file. Prc.lst is the output from the SAS procedure. Prc.sas is the SAS code to run the logistic
        /// procedure. Outest.csv is the parameter output file, and [SampleLocationName].csv is the input data used by the sas procedure.
        /// </summary>
        public void runSasProcedure()
        {
            IQueryFilter qry = new QueryFilterClass();

            qry.SubFields = dependentfield;
            IFeatureCursor fCur   = samplelocations.Search(qry, false);
            int            dIndex = fCur.FindField(dependentfield);
            IFeature       fRow   = fCur.NextFeature();
            List <string>  sLst   = new List <string>();

            while (fRow != null)
            {
                string vl = fRow.get_Value(dIndex).ToString();
                if (!sLst.Contains(vl))
                {
                    sLst.Add(vl);
                }
                fRow = fCur.NextFeature();
            }
            sasIntegration sInt = null;

            if (sLst.Count > 2)
            {
                sInt = new sasIntegration(SampleLocations, SasProcedure.GENERLIZED_LOGISTIC);
            }
            else
            {
                sInt = new sasIntegration(SampleLocations, SasProcedure.LOGISTIC);
            }
            sInt.SLS = (System.Convert.ToDouble(SlStay) / 100).ToString();
            sInt.SLE = (System.Convert.ToDouble(SlEnter) / 100).ToString();
            sInt.StepWiseSelection = StepWiseSelection;
            sInt.DependentField    = Dependentfield;
            sInt.DescretFields     = ClassFields;
            sInt.IndependentFields = IndependentFields;
            sInt.Validation        = Validate;
            sInt.Weightfield       = WeightField;
            SasOutputFile          = sInt.RunProcedure();
            outRest = sInt.OutResultsPath;
            outLog  = sInt.OutLogPath;
            outSas  = sInt.OutSasPath;
        }
        public static void QueryDataByOrder(IFeatureClass featureCls)
        {
            IQueryFilter qf = new QueryFilterClass();

            qf.SubFields = "zldwdm";
            //,sum(TBMJ) as mj,count(*) as num
            //qf .WhereClause="1=1";
            ((IQueryFilterDefinition)qf).PostfixClause = "order by zldwdm ";

            IFeatureCursor feacur = featureCls.Search(qf, false);

            //todo:
            var  zlFieldIndex = feacur.FindField("zldwdm");
            IRow row          = feacur.NextFeature();

            while (row != null)
            {
                var dm = row.get_Value(zlFieldIndex);
                row = feacur.NextFeature();
            }
        }
示例#14
0
        public void CleanUnionResults(string UnionPath)
        {
            IFeatureClass fc;
            IQueryFilter  qf;
            int           SUITABILIT;
            int           OCCUP_MALE;
            int           OCCUP_FEMA;
            int           SUITABIL_1;
            int           OCCUP_MA_1;
            int           OCCUP_FE_1;
            string        suitValue;
            string        occMale;
            string        occFemale;

            GetFeatureClassFromFileName(UnionPath, out fc, out qf);
            IField field = fc.Fields.get_Field(2);

            qf.WhereClause = field.AliasName + " = -1";
            IFeatureCursor curr = fc.Update(qf, false);

            SUITABILIT = curr.FindField("SUITABILIT");
            OCCUP_MALE = curr.FindField("OCCUP_MALE");
            OCCUP_FEMA = curr.FindField("OCCUP_FEMA");
            SUITABIL_1 = curr.FindField("SUITABIL_1");
            OCCUP_MA_1 = curr.FindField("OCCUP_MA_1");
            OCCUP_FE_1 = curr.FindField("OCCUP_FE_1");

            IFeature feat = curr.NextFeature();

            while (feat != null)
            {
                suitValue = feat.get_Value(SUITABIL_1).ToString();
                occMale   = feat.get_Value(OCCUP_MA_1).ToString();
                occFemale = feat.get_Value(OCCUP_FE_1).ToString();

                feat.set_Value(SUITABILIT, suitValue);
                feat.set_Value(OCCUP_MALE, occMale);
                feat.set_Value(OCCUP_FEMA, occFemale);

                feat.Store();
                feat = curr.NextFeature();
            }
            curr.Flush();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(fc);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(qf);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(curr);
        }
示例#15
0
 public static void GetUniqueValues(IFeatureClass featureClass, string string_0, List <ItemInfo> ilist_0,
                                    string whereClause = "")
 {
     try
     {
         IQueryFilter queryFilter = new QueryFilter();
         (queryFilter as IQueryFilterDefinition).PostfixClause = "Order by " + string_0;
         IFeatureCursor featureCursor = featureClass.Search(queryFilter, false);
         int            idx           = featureCursor.FindField(string_0);
         IFeature       feature;
         while ((feature = featureCursor.NextFeature()) != null)
         {
             string value = ConvertToString(feature.Value[idx]);
             ilist_0.Add(new ItemInfo(feature.OID, value));
         }
         Marshal.ReleaseComObject(featureCursor);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
示例#16
0
        /// <summary>
        /// 得到图幅号
        /// </summary>
        /// <param name="ev"></param>
        /// <returns></returns>
        public static void CreateTuFuFeautre(IEnvelope ev, IFeatureClass featureClass)
        {
            IPoint pt1 = ev.UpperLeft;

            if (pt1.IsEmpty)
            {
                return;
            }
            IPoint         pt2  = ev.UpperRight;
            IPoint         pt4  = ev.LowerRight;
            IList <string> list = new List <string>();
            double         y1   = pt1.Y;
            double         y4   = pt4.Y;

            IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
            IFeatureCursor cursor        = featureClass.Insert(true);
            int            index         = cursor.FindField("TuFu");

            while (y1 > y4)
            {
                double x1 = pt1.X;
                double x2 = pt2.X;
                while (x1 < x2)
                {
                    string tufu = GetTuFu(x1, y1);
                    list.Add(tufu);
                    IPointCollection pc      = GeTuPointCollection(x1, y1);
                    IPolygon         polygon = ArcGisUtils.CreatePolygon(pc);

                    featureBuffer.Shape = polygon;
                    featureBuffer.set_Value(3, tufu);
                    cursor.InsertFeature(featureBuffer);

                    x1 += 500;
                }
                y1 -= 500;
            }
        }
示例#17
0
        /// <summary>
        /// Runs the SAS logistic procedure must have a SampleLocations, OutWorkspace, DependentField, IndependentFields, ClassFields, and optionally Validate and Weight must be specified to run
        /// Running the procedure will create a series of files within the SAS output directory (Workspace path \\SASOUTPUT) These files include; prc.log, prc.sas, prc.lst, outest.csv, and another csv
        /// file of the sample data named after the sample location feature class. Prc.log is the SAS log file. Prc.lst is the output from the SAS procedure. Prc.sas is the SAS code to run the logistic
        /// procedure. Outest.csv is the parameter output file, and [SampleLocationName].csv is the input data used by the sas procedure.
        /// </summary>
        public void runSasProcedure()
        {
            IQueryFilter qry = new QueryFilterClass();

            qry.SubFields = MapField;
            IFeatureCursor fCur   = samplelocations.Search(qry, false);
            int            dIndex = fCur.FindField(MapField);
            IFeature       fRow   = fCur.NextFeature();
            List <string>  sLst   = new List <string>();

            while (fRow != null)
            {
                string vl = fRow.get_Value(dIndex).ToString();
                if (!sLst.Contains(vl))
                {
                    sLst.Add(vl);
                }
                fRow = fCur.NextFeature();
            }
            sasIntegration sInt = new sasIntegration(SampleLocations, SasProcedure.ACCURACYASSESSMENT);

            sInt.Alpha             = Alpha;
            sInt.DependentField    = MapField;
            sInt.DescretFields     = ClassFields;
            sInt.IndependentFields = new string[] { ReferenceField };
            sInt.Weightfield       = WeightField;
            sInt.Validation        = false;
            sInt.StepWiseSelection = Exact;
            SasOutputFile          = sInt.RunProcedure();
            outRest = sInt.OutResultsPath;
            outLog  = sInt.OutLogPath;
            outSas  = sInt.OutSasPath;
            if (InTable != null)
            {
                addConfidenceIntervals();
            }
        }
示例#18
0
        private void btnKeySearch_Click(object sender, EventArgs e)
        {
            if (cmbIndexMap.SelectedIndex < 0)
            {
                MessageService.Current.Warn("请选择索引图!");
                return;
            }
            if (string.IsNullOrEmpty(txtSearchKey.EditValue.ToString()))
            {
                MessageService.Current.Warn("请输入搜素关键字!");
                return;
            }
            IIndexMap      indexMap = _indexMaps[cmbIndexMap.SelectedIndex];
            IFeatureCursor pCursor  = indexMap.Search(txtSearchKey.Text);

            if (pCursor == null)
            {
                return;
            }
            IFeature pFeature = pCursor.NextFeature();
            int      nameIdx  = pCursor.FindField(indexMap.NameField);

            lstIndexFeatures.Items.Clear();
            while (pFeature != null)
            {
                string pName = nameIdx >= 0 ? pFeature.Value[nameIdx].ToString() : "";
                if (!pFeature.Shape.IsEmpty)
                {
                    IndexFeatureItem item = new IndexFeatureItem(pFeature.OID, pFeature.Shape.Envelope, pName);
                    lstIndexFeatures.Items.Add(item);
                }

                pFeature = pCursor.NextFeature();
            }
            ComReleaser.ReleaseCOMObject(pCursor);
        }
示例#19
0
        public void summarizeBiomass()
        {
            try
            {
                if (SubPlotField == null)
                {
                    SubPlotField = "";
                }
                //Console.WriteLine("Creating FIlling Plots Table");
                createAndFillPlotsTable();
                //Console.WriteLine("Creating And Filling Tree Ref Table");
                createAndFillTreesRef();
                //Console.WriteLine("Adding fields");
                //need to add in groups and update unSp
                addFields();
                if (regen)
                {
                    createAndFillRegenRef();
                    //System.Windows.Forms.MessageBox.Show(String.Join(", ", rgDic.Keys.ToArray()));
                    addRegenFields();
                }
                if (less5)
                {
                    addFields("s");
                }
                IQueryFilter   qryFlt   = new QueryFilterClass();
                string         nFldNm   = "";
                string         fldNm    = "";
                IFeatureCursor ftrCur   = SampleFeatureClass.Update(null, true);
                IFeature       ftr      = ftrCur.NextFeature();
                int            cnIndex  = ftrCur.FindField(PlotCnField);
                int            subIndex = ftrCur.FindField(SubPlotField);
                double         divs     = (43560 / (Math.PI * Math.Pow(24, 2)));
                double         rdivs    = (43560 / (Math.PI * Math.Pow(6.8, 2)));
                if (SubPlotField == "" || SubPlotField == null)
                {
                    divs  = divs / 4;
                    rdivs = rdivs / 4;
                }
                List <string> allEstFld = Enum.GetNames(typeof(biomassTypes)).ToList();
                while (ftr != null)
                {
                    string pCn = ftr.get_Value(cnIndex).ToString();
                    int    sPl = 0;
                    if (subIndex > -1)
                    {
                        sPl = System.Convert.ToInt32(ftr.get_Value(subIndex));
                    }
                    if (regen)
                    {
                        foreach (string rt in rUnSp)
                        {
                            string ky = pCn + "_" + sPl + "_" + rt;
                            int    rgCnt;
                            double cnt = 0;
                            if (rgDic.TryGetValue(ky, out rgCnt))
                            {
                                cnt = rdivs * rgCnt;
                            }
                            else
                            {
                                cnt = 0;
                            }
                            int rgIndex = ftr.Fields.FindField("RTPA_" + rt);
                            ftr.set_Value(rgIndex, cnt);
                        }
                    }
                    if (less5)
                    {
                        foreach (string t in sUnSp)                  //(biomassTypes s in fldArr)
                        {
                            string   ky = pCn + "_" + sPl + "_" + t; //CN_SubPlot_species
                            object[] vls;
                            if (sVlDic.TryGetValue(ky, out vls))
                            {
                            }
                            else
                            {
                                vls     = new object[12];
                                vls[0]  = pCn;
                                vls[1]  = sPl;
                                vls[2]  = t;
                                vls[3]  = 0; //MDBH
                                vls[4]  = 0; //AGB
                                vls[5]  = 0; //StemAGB
                                vls[6]  = 0; //ButtAGB
                                vls[7]  = 0; //FoliageAGB
                                vls[8]  = 0; //TopAGB
                                vls[9]  = 0; //BAA
                                vls[10] = 0; //TPA
                                vls[11] = 0; //MHT
                            }
                            foreach (biomassTypes s in fldArr)
                            {
                                string btStr      = s.ToString();
                                int    arrayIndex = allEstFld.IndexOf(btStr);
                                double sdivs2     = rdivs;
                                if (arrayIndex <= 1)
                                {
                                    arrayIndex = 9 + arrayIndex;
                                }
                                else
                                {
                                    if (arrayIndex <= 6)
                                    {
                                        arrayIndex = 2 + arrayIndex;
                                        sdivs2     = rdivs / 2000;//tons
                                    }
                                    else if (arrayIndex == 7)
                                    {
                                        arrayIndex = 3;
                                        double d = System.Convert.ToDouble(vls[10]);
                                        if (d < 1)
                                        {
                                            sdivs2 = 1;
                                        }
                                        else
                                        {
                                            sdivs2 = 1 / d;
                                        }
                                    }
                                    else
                                    {
                                        arrayIndex = 11;
                                        double d = System.Convert.ToDouble(vls[10]);
                                        if (d < 1)
                                        {
                                            sdivs2 = 1;
                                        }
                                        else
                                        {
                                            sdivs2 = 1 / d;
                                        }
                                    }
                                }

                                string spCd = vls[2].ToString();
                                fldNm = "s" + s + "_" + spCd;
                                //Console.WriteLine(fldNm);
                                int fldIndex = ftrCur.FindField(fldNm);
                                if (fldIndex == -1)
                                {
                                    fldIndex = ftrCur.FindField(nFldNm.Substring(0, 10));
                                }
                                object vl = (System.Convert.ToDouble(vls[arrayIndex])) * sdivs2;
                                ftr.set_Value(fldIndex, vl);
                            }
                        }
                    }

                    foreach (string t in unSp)                   //(biomassTypes s in fldArr)
                    {
                        string   ky = pCn + "_" + sPl + "_" + t; //CN_SubPlot_species
                        object[] vls;
                        if (vlDic.TryGetValue(ky, out vls))
                        {
                        }
                        else
                        {
                            vls     = new object[12];
                            vls[0]  = pCn;
                            vls[1]  = sPl;
                            vls[2]  = t;
                            vls[3]  = 0; //MDBH
                            vls[4]  = 0; //AGB
                            vls[5]  = 0; //StemAGB
                            vls[6]  = 0; //ButtAGB
                            vls[7]  = 0; //FoliageAGB
                            vls[8]  = 0; //TopAGB
                            vls[9]  = 0; //BAA
                            vls[10] = 0; //TPA
                            vls[11] = 0; //MHT
                        }
                        foreach (biomassTypes s in fldArr)
                        {
                            string btStr      = s.ToString();
                            int    arrayIndex = allEstFld.IndexOf(btStr);
                            double divs2      = divs;
                            if (arrayIndex <= 1)
                            {
                                arrayIndex = 9 + arrayIndex;
                            }
                            else
                            {
                                if (arrayIndex <= 6)
                                {
                                    arrayIndex = 2 + arrayIndex;
                                    divs2      = divs / 2000;//tons
                                }
                                else if (arrayIndex == 7)
                                {
                                    arrayIndex = 3;
                                    double d = System.Convert.ToDouble(vls[10]);
                                    if (d < 1)
                                    {
                                        divs2 = 1;
                                    }
                                    else
                                    {
                                        divs2 = 1 / d;
                                    }
                                }
                                else
                                {
                                    arrayIndex = 11;
                                    double d = System.Convert.ToDouble(vls[10]);
                                    if (d < 1)
                                    {
                                        divs2 = 1;
                                    }
                                    else
                                    {
                                        divs2 = 1 / d;
                                    }
                                }
                            }

                            string spCd = vls[2].ToString();
                            fldNm = s + "_" + spCd;
                            //Console.WriteLine(fldNm);
                            int fldIndex = ftrCur.FindField(fldNm);
                            if (fldIndex == -1)
                            {
                                fldIndex = ftrCur.FindField(nFldNm.Substring(0, 10));
                            }
                            object vl = (System.Convert.ToDouble(vls[arrayIndex])) * divs2;
                            ftr.set_Value(fldIndex, vl);
                        }
                    }
                    ftrCur.UpdateFeature(ftr);
                    ftr = ftrCur.NextFeature();
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(ftrCur);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                //System.Environment.OSVersion.
                if (av == "0.0" || ev == "0.0")
                {
                    System.Windows.Forms.MessageBox.Show("You do not have OleDB 12.0 installed. Please download and install Office 2007 data provider from:\nhttp://www.microsoft.com/en-us/download/confirmation.aspx?id=23734", "No data provider found", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }
                else
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }
示例#20
0
        private void calcZoneValuesFtr()
        {
            //Console.WriteLine("made it to the feature calculations");
            bool makeDic = (ZoneClassCount || ZoneTypes.Contains(rasterUtil.zoneType.VARIETY) || ZoneTypes.Contains(rasterUtil.zoneType.ENTROPY) || ZoneTypes.Contains(rasterUtil.zoneType.ASM) || ZoneTypes.Contains(rasterUtil.zoneType.MINORITY) || ZoneTypes.Contains(rasterUtil.zoneType.MODE) || ZoneTypes.Contains(rasterUtil.zoneType.MEDIAN));
            //
            //HashSet<byte> hByt = new HashSet<byte>();
            //
            ISpatialReference sr     = vRs.RasterInfo.SpatialReference;
            IEnvelope         vrsEnv = vRs.RasterInfo.Extent;
            ISpatialFilter    spFilt = new SpatialFilterClass();

            spFilt.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
            spFilt.Geometry      = vrsEnv;
            spFilt.GeometryField = ftrCls.ShapeFieldName;
            IFeatureCursor fCur      = ftrCls.Search(spFilt, true);
            int            zoneIndex = fCur.FindField(InZoneField);
            IFeature       ftr       = fCur.NextFeature();

            while (ftr != null)
            {
                IGeometry geo  = ftr.Shape;
                double    z    = System.Convert.ToDouble(ftr.get_Value(zoneIndex));
                IPolygon4 poly = (IPolygon4)geo;
                if (needToProject)
                {
                    poly.Project(sr);
                }
                IGeometryBag        geoBag  = poly.ExteriorRingBag;
                IGeometryCollection geoColl = (IGeometryCollection)geoBag;
                for (int g = 0; g < geoColl.GeometryCount; g++)
                {
                    IGeometry geo2                  = geoColl.Geometry[g];
                    IFunctionRasterDataset rs       = rsUtil.clipRasterFunction(vRs, geo2, esriRasterClippingType.esriRasterClippingOutside);
                    IEnvelope             rsEnv     = rs.RasterInfo.Extent;
                    IRasterFunctionHelper rsFHelper = new RasterFunctionHelperClass();
                    rsFHelper.Bind(rs);
                    //Console.WriteLine((rsEnv.Width / 30).ToString() + ", " + (rsEnv.Height / 30).ToString());
                    IRasterCursor rsCur = ((IRaster2)rsFHelper.Raster).CreateCursorEx(null);
                    do
                    {
                        IPixelBlock pb = rsCur.PixelBlock;
                        for (int p = 0; p < pb.Planes; p++)
                        {
                            zoneValueDic = zoneValueDicArr[p];
                            object[] zoneValue;
                            double   cnt   = 0;
                            double   maxVl = Double.MinValue;
                            double   minVl = Double.MaxValue;
                            double   s     = 0;
                            double   s2    = 0;
                            Dictionary <double, int> uDic = null;
                            if (zoneValueDic.TryGetValue(z, out zoneValue))
                            {
                                cnt   = System.Convert.ToDouble(zoneValue[0]);
                                maxVl = System.Convert.ToDouble(zoneValue[1]);
                                minVl = System.Convert.ToDouble(zoneValue[2]);
                                s     = System.Convert.ToDouble(zoneValue[3]);
                                s2    = System.Convert.ToDouble(zoneValue[4]);
                                uDic  = (Dictionary <double, int>)zoneValue[5];
                            }
                            else
                            {
                                zoneValue    = new object[6];
                                zoneValue[0] = cnt;
                                zoneValue[1] = maxVl;
                                zoneValue[2] = minVl;
                                zoneValue[3] = s;
                                zoneValue[4] = s2;
                                uDic         = null;
                                if (makeDic)
                                {
                                    uDic = new Dictionary <double, int>();
                                }
                                zoneValue[5] = uDic;
                            }
                            for (int r = 0; r < pb.Height; r++)
                            {
                                for (int c = 0; c < pb.Width; c++)
                                {
                                    object vlo = pb.GetVal(p, c, r);
                                    if (vlo == null)
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        double vl = System.Convert.ToDouble(vlo);
                                        cnt++;
                                        if (vl > maxVl)
                                        {
                                            maxVl = vl;
                                        }
                                        if (vl < minVl)
                                        {
                                            minVl = vl;
                                        }
                                        s  += vl;
                                        s2 += vl * vl;
                                        if (makeDic)
                                        {
                                            int cntVl = 0;
                                            if (uDic.TryGetValue(vl, out cntVl))
                                            {
                                                uDic[vl] = cntVl += 1;
                                            }
                                            else
                                            {
                                                uDic.Add(vl, 1);
                                            }
                                        }
                                    }
                                }
                            }
                            zoneValue[0]    = cnt;
                            zoneValue[1]    = maxVl;
                            zoneValue[2]    = minVl;
                            zoneValue[3]    = s;
                            zoneValue[4]    = s2;
                            zoneValue[5]    = uDic;
                            zoneValueDic[z] = zoneValue;
                        }
                    } while (rsCur.Next());
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(rsCur);
                }
                ftr = fCur.NextFeature();
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(fCur);
        }
        private void button3_Click(object sender, EventArgs e)
        {
            QZ quanzhong;

            quanzhong.MD = 0;
            quanzhong.BL = 0;
            quanzhong.HB = 0;
            quanzhong.PD = 0;
            quanzhong.JL = 0;
            quanzhong.LS = 0;

            if (this.listView1.Items != null)
            {
                foreach (ListViewItem item in this.listView1.Items)
                {
                    if (item.SubItems[0].Text == "人口密度")
                    {
                        quanzhong.MD = Convert.ToDouble(item.SubItems[1].Text);
                    }
                    if (item.SubItems[0].Text == "居民地比例")
                    {
                        quanzhong.BL = Convert.ToDouble(item.SubItems[1].Text);
                    }
                    if (item.SubItems[0].Text == "平均海拔")
                    {
                        quanzhong.HB = Convert.ToDouble(item.SubItems[1].Text);
                    }
                    if (item.SubItems[0].Text == "平均坡度")
                    {
                        quanzhong.PD = Convert.ToDouble(item.SubItems[1].Text);
                    }
                    if (item.SubItems[0].Text == "与公路距离")
                    {
                        quanzhong.JL = Convert.ToDouble(item.SubItems[1].Text);
                    }
                    if (item.SubItems[0].Text == "坡向离散度")
                    {
                        quanzhong.LS = Convert.ToDouble(item.SubItems[1].Text);
                    }
                }
            }

            IFeatureLayer featureLayer = mapControl.get_Layer(17) as IFeatureLayer;
            string        n            = featureLayer.Name;
            IFeatureClass featureClass = featureLayer.FeatureClass;

            IQueryFilter   queryFilter   = new QueryFilterClass();
            IFeatureCursor featureCursor = featureClass.Update(queryFilter, true);

            int MDIndex    = featureCursor.FindField("人口密度");
            int BLIndex    = featureCursor.FindField("居民地比例");
            int HBIndex    = featureCursor.FindField("平均海拔");
            int PDIndex    = featureCursor.FindField("平均坡度");
            int JLIndex    = featureCursor.FindField("与公路距离");
            int LSIndex    = featureCursor.FindField("坡向离散度");
            int scoreIndex = featureCursor.FindField("总分值");



            IFeature feature = featureCursor.NextFeature();

            while (feature != null)
            {
                double MD_t = Convert.ToDouble(feature.get_Value(MDIndex));
                double BL_t = Convert.ToDouble(feature.get_Value(BLIndex));
                double HB_t = Convert.ToDouble(feature.get_Value(HBIndex));
                double PD_t = Convert.ToDouble(feature.get_Value(PDIndex));
                double JL_t = Convert.ToDouble(feature.get_Value(JLIndex));
                double LS_t = Convert.ToDouble(feature.get_Value(LSIndex));


                double totalScore = quanzhong.MD * MD_t + quanzhong.BL * BL_t + quanzhong.HB * HB_t + quanzhong.PD * PD_t + quanzhong.JL * JL_t + quanzhong.LS * LS_t;

                feature.set_Value(scoreIndex, totalScore);
                featureCursor.UpdateFeature(feature);
                feature = featureCursor.NextFeature();
                featureCursor.UpdateFeature(feature);
                feature = featureCursor.NextFeature();
            }
        }
示例#22
0
        protected override void OnClick()
        {
            bool            bShowProgressor = false;
            IStepProgressor pStepProgressor = null;
            //Create a CancelTracker.
            ITrackCancel           pTrackCancel = null;
            IProgressDialogFactory pProgressorDialogFact;

            IMouseCursor pMouseCursor = new MouseCursorClass();

            pMouseCursor.SetCursor(2);

            //first get the selected parcel features
            UID pUID = new UIDClass();

            pUID.Value = "{114D685F-99B7-4B63-B09F-6D1A41A4DDC1}";
            ICadastralExtensionManager2 pCadExtMan = (ICadastralExtensionManager2)ArcMap.Application.FindExtensionByCLSID(pUID);
            ICadastralEditor            pCadEd     = (ICadastralEditor)ArcMap.Application.FindExtensionByCLSID(pUID);

            //check if there is a Manual Mode "modify" job active ===========
            ICadastralPacketManager pCadPacMan = (ICadastralPacketManager)pCadExtMan;

            if (pCadPacMan.PacketOpen)
            {
                MessageBox.Show("The Delete Control command cannot be used when there is an open job.\r\nPlease finish or discard the open job, and try again.",
                                "Delete Selected Control");
                return;
            }

            IEditor pEd = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor");

            IActiveView      pActiveView       = ArcMap.Document.ActiveView;
            IMap             pMap              = pActiveView.FocusMap;
            ICadastralFabric pCadFabric        = null;
            clsFabricUtils   FabricUTILS       = new clsFabricUtils();
            IProgressDialog2 pProgressorDialog = null;

            //if we're in an edit session then grab the target fabric
            if (pEd.EditState == esriEditState.esriStateEditing)
            {
                pCadFabric = pCadEd.CadastralFabric;
            }

            if (pCadFabric == null)
            {//find the first fabric in the map
                if (!FabricUTILS.GetFabricFromMap(pMap, out pCadFabric))
                {
                    MessageBox.Show
                        ("No Parcel Fabric found in the map.\r\nPlease add a single fabric to the map, and try again.");
                    return;
                }
            }

            IArray CFControlLayers = new ArrayClass();

            if (!(FabricUTILS.GetControlLayersFromFabric(pMap, pCadFabric, out CFControlLayers)))
            {
                return; //no fabric sublayers available for the targeted fabric
            }
            bool       bIsFileBasedGDB = false; bool bIsUnVersioned = false; bool bUseNonVersionedDelete = false;
            IWorkspace pWS           = null;
            ITable     pPointsTable  = null;
            ITable     pControlTable = null;

            try
            {
                if (pEd.EditState == esriEditState.esriStateEditing)
                {
                    try
                    {
                        pEd.StartOperation();
                    }
                    catch
                    {
                        pEd.AbortOperation();//abort any open edit operations and try again
                        pEd.StartOperation();
                    }
                }

                IFeatureLayer pFL = (IFeatureLayer)CFControlLayers.get_Element(0);
                IDataset      pDS = (IDataset)pFL.FeatureClass;
                pWS = pDS.Workspace;

                if (!FabricUTILS.SetupEditEnvironment(pWS, pCadFabric, pEd, out bIsFileBasedGDB,
                                                      out bIsUnVersioned, out bUseNonVersionedDelete))
                {
                    return;
                }

                //loop through each control layer and
                //Get the selection of control
                int iCnt = 0;
                int iTotalSelectionCount = 0;
                for (; iCnt < CFControlLayers.Count; iCnt++)
                {
                    pFL = (IFeatureLayer)CFControlLayers.get_Element(iCnt);
                    IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
                    ISelectionSet2    pSelSet  = (ISelectionSet2)pFeatSel.SelectionSet;
                    iTotalSelectionCount += pSelSet.Count;
                }

                if (iTotalSelectionCount == 0)
                {
                    MessageBox.Show("Please select some fabric control points and try again.", "No Selection",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (bUseNonVersionedDelete)
                    {
                        pCadEd.CadastralFabricLayer = null;
                        CFControlLayers             = null;
                    }
                    return;
                }

                bShowProgressor = (iTotalSelectionCount > 10);

                if (bShowProgressor)
                {
                    pProgressorDialogFact       = new ProgressDialogFactoryClass();
                    pTrackCancel                = new CancelTrackerClass();
                    pStepProgressor             = pProgressorDialogFact.Create(pTrackCancel, ArcMap.Application.hWnd);
                    pProgressorDialog           = (IProgressDialog2)pStepProgressor;
                    pStepProgressor.MinRange    = 1;
                    pStepProgressor.MaxRange    = iTotalSelectionCount * 2; //(runs through selection twice)
                    pStepProgressor.StepValue   = 1;
                    pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
                }

                //loop through each control layer and
                //delete from its selection
                m_pQF = new QueryFilterClass();
                iCnt  = 0;
                for (; iCnt < CFControlLayers.Count; iCnt++)
                {
                    pFL = (IFeatureLayer)CFControlLayers.get_Element(iCnt);
                    IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
                    ISelectionSet2    pSelSet  = (ISelectionSet2)pFeatSel.SelectionSet;

                    ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
                    string     sPref      = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
                    string     sSuff      = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);

                    if (bShowProgressor)
                    {
                        pProgressorDialog.ShowDialog();
                        pStepProgressor.Message = "Collecting Control point data...";
                    }

                    //Add the OIDs of all the selected control points into a new feature IDSet
                    string[] sOIDListPoints = { "(" };
                    int      tokenLimit     = 995;
                    //int tokenLimit = 5; //temp for testing
                    bool bCont    = true;
                    int  j        = 0;
                    int  iCounter = 0;

                    m_pFIDSetControl = new FIDSetClass();

                    ICursor pCursor = null;
                    pSelSet.Search(null, false, out pCursor);//code deletes all selected control points
                    IFeatureCursor pControlFeatCurs = (IFeatureCursor)pCursor;
                    IFeature       pControlFeat     = pControlFeatCurs.NextFeature();
                    int            iPointID         = pControlFeatCurs.FindField("POINTID");

                    while (pControlFeat != null)
                    {
                        //Check if the cancel button was pressed. If so, stop process
                        if (bShowProgressor)
                        {
                            bCont = pTrackCancel.Continue();
                            if (!bCont)
                            {
                                break;
                            }
                        }
                        bool bExists = false;
                        m_pFIDSetControl.Find(pControlFeat.OID, out bExists);
                        if (!bExists)
                        {
                            m_pFIDSetControl.Add(pControlFeat.OID);
                            object obj = pControlFeat.get_Value(iPointID);

                            if (iCounter <= tokenLimit)
                            {
                                //if the PointID is not null add it to a query string as well
                                if (obj != DBNull.Value)
                                {
                                    sOIDListPoints[j] += Convert.ToString(obj) + ",";
                                }
                                iCounter++;
                            }
                            else
                            {//maximum tokens reached
                                //set up the next OIDList
                                sOIDListPoints[j] = sOIDListPoints[j].Trim();
                                iCounter          = 0;
                                j++;
                                FabricUTILS.RedimPreserveString(ref sOIDListPoints, 1);
                                sOIDListPoints[j] = "(";
                                if (obj != DBNull.Value)
                                {
                                    sOIDListPoints[j] += Convert.ToString(obj) + ",";
                                }
                            }
                        }
                        Marshal.ReleaseComObject(pControlFeat); //garbage collection
                        pControlFeat = pControlFeatCurs.NextFeature();

                        if (bShowProgressor)
                        {
                            if (pStepProgressor.Position < pStepProgressor.MaxRange)
                            {
                                pStepProgressor.Step();
                            }
                        }
                    }
                    Marshal.ReleaseComObject(pCursor); //garbage collection

                    if (!bCont)
                    {
                        AbortEdits(bUseNonVersionedDelete, pEd, pWS);
                        return;
                    }

                    if (bUseNonVersionedDelete)
                    {
                        if (!FabricUTILS.StartEditing(pWS, bIsUnVersioned))
                        {
                            if (bUseNonVersionedDelete)
                            {
                                pCadEd.CadastralFabricLayer = null;
                            }
                            return;
                        }
                    }

                    //first delete all the control point records
                    if (bShowProgressor)
                    {
                        pStepProgressor.Message = "Deleting control points...";
                    }

                    bool bSuccess = true;
                    pPointsTable  = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPoints);
                    pControlTable = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTControl);

                    if (!bUseNonVersionedDelete)
                    {
                        bSuccess = FabricUTILS.DeleteRowsByFIDSet(pControlTable, m_pFIDSetControl, pStepProgressor, pTrackCancel);
                    }
                    if (bUseNonVersionedDelete)
                    {
                        bSuccess = FabricUTILS.DeleteRowsUnversioned(pWS, pControlTable,
                                                                     m_pFIDSetControl, pStepProgressor, pTrackCancel);
                    }
                    if (!bSuccess)
                    {
                        AbortEdits(bUseNonVersionedDelete, pEd, pWS);
                        return;
                    }
                    //next need to use an in clause to update the points, ...
                    ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)pCadFabric;
                    //...for each item in the sOIDListPoints array
                    foreach (string inClause in sOIDListPoints)
                    {
                        string sClause = inClause.Trim().TrimEnd(',');
                        if (sClause.EndsWith("("))
                        {
                            continue;
                        }
                        if (sClause.Length < 3)
                        {
                            continue;
                        }
                        pSchemaEd.ReleaseReadOnlyFields(pPointsTable, esriCadastralFabricTable.esriCFTPoints);
                        m_pQF.WhereClause = (sPref + pPointsTable.OIDFieldName + sSuff).Trim() + " IN " + sClause + ")";

                        if (!FabricUTILS.ResetPointAssociations(pPointsTable, m_pQF, bIsUnVersioned))
                        {
                            pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTPoints);
                            return;
                        }
                        pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTPoints);
                    }
                }

                if (bUseNonVersionedDelete)
                {
                    FabricUTILS.StopEditing(pWS);
                }

                if (pEd.EditState == esriEditState.esriStateEditing)
                {
                    pEd.StopOperation("Delete Control Points");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            finally
            {
                RefreshMap(pActiveView, CFControlLayers);

                //update the TOC
                IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)(ArcMap.Application.Document);
                for (int i = 0; i < mxDocument.ContentsViewCount; i++)
                {
                    IContentsView pCV = (IContentsView)mxDocument.get_ContentsView(i);
                    pCV.Refresh(null);
                }

                if (pProgressorDialog != null)
                {
                    pProgressorDialog.HideDialog();
                }

                if (bUseNonVersionedDelete)
                {
                    pCadEd.CadastralFabricLayer = null;
                    CFControlLayers             = null;
                }

                if (pMouseCursor != null)
                {
                    pMouseCursor.SetCursor(0);
                }
            }
        }
示例#23
0
        public void Execute()
        {
            try {
                // Create new spatial reference
                ISpatialReference spatialReference = null;
                if (this.SRef.ToLowerInvariant().Contains("projcs"))
                {
                    spatialReference = new ProjectedCoordinateSystemClass();
                }
                else
                {
                    spatialReference = new GeographicCoordinateSystemClass();
                }

                // Import SpatialReference Definition
                int bytes2;
                IESRISpatialReferenceGEN2 gen = (IESRISpatialReferenceGEN2)spatialReference;
                gen.ImportFromESRISpatialReference(this.SRef, out bytes2);

                // Create Search Extent
                IEnvelope extent = new EnvelopeClass();
                extent.PutCoords(this.XMin, this.YMin, this.XMax, this.YMax);
                extent.SpatialReference = spatialReference;

                // Open Saved Layer File
                ILayerFile layerFile = new LayerFileClass();
                layerFile.Open(this.Path);
                ILayer layer = layerFile.Layer;
                layerFile.Close();

                // Where clause and list of selected OIDs
                string where = string.Empty;
                List <int> ids = new List <int>();

                IImageServerLayer imageLayer = null;
                if (layer is IImageServerLayer)
                {
                    imageLayer = (IImageServerLayer)layer;

                    // Get Selection Set
                    IFeatureLayerDefinition definition = layer as IFeatureLayerDefinition;
                    if (definition != null)
                    {
                        // Find Selected OIDs
                        if (definition.DefinitionSelectionSet != null)
                        {
                            if (definition.DefinitionSelectionSet.Count > 0)
                            {
                                IEnumIDs emumids = definition.DefinitionSelectionSet.IDs;
                                int      id      = emumids.Next();
                                while (id != -1)
                                {
                                    ids.Add(id);
                                    id = emumids.Next();
                                }
                            }
                        }

                        // Update Where Clause
                        if (!string.IsNullOrEmpty(definition.DefinitionExpression))
                        {
                            where = definition.DefinitionExpression;
                        }
                    }
                }
                else if (layer is IMosaicLayer)
                {
                    IMosaicLayer mosaicLayer = (IMosaicLayer)layer;
                    imageLayer = mosaicLayer.PreviewLayer;
                    ITableDefinition tableDefinition = mosaicLayer as ITableDefinition;
                    if (tableDefinition != null)
                    {
                        // Find Selected OIDs
                        if (tableDefinition.DefinitionSelectionSet != null)
                        {
                            if (tableDefinition.DefinitionSelectionSet.Count > 0)
                            {
                                IEnumIDs emumids = tableDefinition.DefinitionSelectionSet.IDs;
                                int      id      = emumids.Next();
                                while (id != -1)
                                {
                                    ids.Add(id);
                                    id = emumids.Next();
                                }
                            }
                        }

                        // Update Where Clause
                        if (!string.IsNullOrEmpty(tableDefinition.DefinitionExpression))
                        {
                            where = tableDefinition.DefinitionExpression;
                        }
                    }
                }

                // Use FeatureSelected (if any)
                IFeatureSelection featureSelection = imageLayer as IFeatureSelection;
                if (featureSelection != null)
                {
                    if (featureSelection.SelectionSet != null)
                    {
                        if (featureSelection.SelectionSet.Count > 0)
                        {
                            IEnumIDs emumids = featureSelection.SelectionSet.IDs;
                            int      id      = emumids.Next();
                            while (id != -1)
                            {
                                ids.Add(id);
                                id = emumids.Next();
                            }
                        }
                    }
                }

                // Get Bands
                ILongArray      bands          = new LongArrayClass();
                IRasterRenderer rasterRenderer = imageLayer.Renderer;
                if (rasterRenderer != null)
                {
                    IRasterRGBRenderer2 rasterRGBRenderer = rasterRenderer as IRasterRGBRenderer2;
                    if (rasterRGBRenderer != null)
                    {
                        bands.Add(rasterRGBRenderer.UseRedBand ? rasterRGBRenderer.RedBandIndex : -1);
                        bands.Add(rasterRGBRenderer.UseGreenBand ? rasterRGBRenderer.GreenBandIndex : -1);
                        bands.Add(rasterRGBRenderer.UseBlueBand ? rasterRGBRenderer.BlueBandIndex : -1);
                        bands.Add(rasterRGBRenderer.UseAlphaBand ? rasterRGBRenderer.AlphaBandIndex : -1);
                    }
                }

                // Create Spatial Filter
                ISpatialFilter spatialFilter = new SpatialFilterClass()
                {
                    Geometry    = extent,
                    SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects,
                    WhereClause = where
                };

                IImageServer imageServer = imageLayer.DataSource as IImageServer;
                if (imageServer == null)
                {
                    return;
                }
                IImageServer3 imageServer3 = imageServer as IImageServer3;
                if (imageServer3 == null)
                {
                    return;
                }
                IRecordSet      recordSet     = imageServer3.GetCatalogItems(spatialFilter);
                ICursor         cursor        = recordSet.get_Cursor(false);
                IFeatureCursor  featureCursor = (IFeatureCursor)cursor;
                IFeature        feature       = featureCursor.NextFeature();
                List <IFeature> list          = new List <IFeature>();

                int indexCategory = featureCursor.FindField("Category");

                while (feature != null)
                {
                    // Exclude non-primary images (no overviews)
                    if (indexCategory != -1)
                    {
                        int cat = (int)feature.get_Value(indexCategory);
                        if (cat != 1)
                        {
                            feature = featureCursor.NextFeature();
                            continue;
                        }
                    }

                    // Exclude unselected features
                    if (ids.Count > 0)
                    {
                        int oid = feature.OID;
                        if (!ids.Contains(oid))
                        {
                            feature = featureCursor.NextFeature();
                            continue;
                        }
                    }

                    list.Add(feature);
                    feature = featureCursor.NextFeature();
                }

                // If nothing, fire event then exit
                if (list.Count == 0)
                {
                    this.OnThumbnailSummary(new SummaryEventArgs());
                    return;
                }

                // Get Full Extent of Features
                SummaryEventArgs summary = new SummaryEventArgs()
                {
                    XMin  = list.Min(f => f.Shape.Envelope.CloneProject(spatialReference).XMin),
                    YMin  = list.Min(f => f.Shape.Envelope.CloneProject(spatialReference).YMin),
                    XMax  = list.Max(f => f.Shape.Envelope.CloneProject(spatialReference).XMax),
                    YMax  = list.Max(f => f.Shape.Envelope.CloneProject(spatialReference).YMax),
                    Count = list.Count
                };

                // Add Fields
                IFields fields = featureCursor.Fields;
                for (int i = 0; i < fields.FieldCount; i++)
                {
                    IField field = fields.get_Field(i);
                    switch (field.Type)
                    {
                    case esriFieldType.esriFieldTypeBlob:
                    case esriFieldType.esriFieldTypeGeometry:
                    case esriFieldType.esriFieldTypeGlobalID:
                    case esriFieldType.esriFieldTypeGUID:
                    case esriFieldType.esriFieldTypeRaster:
                    case esriFieldType.esriFieldTypeXML:
                        break;

                    case esriFieldType.esriFieldTypeOID:
                    case esriFieldType.esriFieldTypeDate:
                    case esriFieldType.esriFieldTypeDouble:
                    case esriFieldType.esriFieldTypeInteger:
                    case esriFieldType.esriFieldTypeSingle:
                    case esriFieldType.esriFieldTypeSmallInteger:
                    case esriFieldType.esriFieldTypeString:
                        summary.Fields.Add(
                            new Field()
                        {
                            Name  = field.Name,
                            Alias = field.AliasName,
                            Type  = field.Type
                        }
                            );
                        break;

                    default:
                        break;
                    }
                }

                // Raise Summary Event
                this.OnThumbnailSummary(summary);

                // Loop for each feature
                foreach (IFeature feat in list)
                {
                    // Project Extent to Current Map Spatial Reference
                    IEnvelope extentMap = feat.Shape.Envelope.CloneProject(spatialReference);

                    int width;
                    int height;
                    if (extentMap.Width > extentMap.Height)
                    {
                        width  = this.MaxImageSize;
                        height = Convert.ToInt32((double)this.MaxImageSize * (double)extentMap.Height / (double)extentMap.Width);
                    }
                    else
                    {
                        width  = Convert.ToInt32((double)this.MaxImageSize * (double)extentMap.Width / (double)extentMap.Height);
                        height = this.MaxImageSize;
                    }

                    IMosaicRule mosaicRule = new MosaicRuleClass()
                    {
                        MosaicMethod = esriMosaicMethod.esriMosaicLockRaster,
                        LockRasterID = feat.OID.ToString()
                    };
                    IGeoImageDescription geoImageDescription = new GeoImageDescriptionClass()
                    {
                        BandSelection    = bands.Count > 0 ? bands : null,
                        MosaicRule       = mosaicRule,
                        Compression      = "PNG",
                        Width            = width,
                        Height           = height,
                        SpatialReference = spatialReference,
                        Extent           = extentMap,
                        Interpolation    = rstResamplingTypes.RSP_BilinearInterpolation,
                    };

                    // Assembly MosaicRequest (will be executed in background thread)
                    MosaicRequest mosaicRequest = new MosaicRequest()
                    {
                        MosaicExtractor     = this,
                        ImageServer         = imageServer3,
                        GeoImageDescription = geoImageDescription,
                        XMin = extentMap.XMin,
                        YMin = extentMap.YMin,
                        XMax = extentMap.XMax,
                        YMax = extentMap.YMax,
                    };

                    // Add Attributes Names and Values
                    foreach (Field field in summary.Fields)
                    {
                        int index = feat.Fields.FindField(field.Name);
                        if (index < 0)
                        {
                            continue;
                        }
                        mosaicRequest.Attributes.Add(field.Name, feat.get_Value(index));
                    }

                    // Start Mosaic Request in Background Thread
                    Thread thread = new Thread(new ThreadStart(mosaicRequest.Execute));
                    MosaicEnvironment.Default.Threads.Add(thread);
                    thread.Start();
                }
            }
            catch { }
        }
示例#24
0
        public override bool Check(ref List <Error> checkResult)
        {
            try
            {
                Hashtable         pHtable      = new Hashtable();
                IFeatureWorkspace pFWs         = m_BaseWorkspace as IFeatureWorkspace;
                IEnumDataset      pEmDs        = m_BaseWorkspace.get_Datasets(esriDatasetType.esriDTFeatureClass);
                IDataset          pDt          = null;
                IQueryFilter      pQueryFilter = new QueryFilterClass();

                List <Error> pResAttr = new List <Error>();
                while ((pDt = pEmDs.Next()) != null)
                {
                    IFeatureClass pFc           = pDt as IFeatureClass;
                    int           bsmFieldIndex = pFc.FindField("bsm");
                    if (bsmFieldIndex == -1)
                    {
                        continue;
                    }
                    pQueryFilter.SubFields = pFc.OIDFieldName + ",bsm";
                    IFeatureCursor pFeatCur = pFc.Search(pQueryFilter, false);
                    IFeature       pFeat    = null;
                    while ((pFeat = pFeatCur.NextFeature()) != null)
                    {
                        string bsm = pFeat.get_Value(bsmFieldIndex).ToString();
                        if (pHtable.Contains(bsm))
                        {
                            Error pResInfo = new Error();
                            pResInfo.DefectLevel = this.m_DefectLevel;
                            pResInfo.RuleID      = this.InstanceID;

                            pResInfo.OID         = pFeat.OID;
                            pResInfo.BSM         = bsm;
                            pResInfo.Description = string.Format(Helper.ErrMsgFormat.ERR_630100001, pFc.AliasName, pHtable[bsm].ToString(), bsm);
                            pResInfo.LayerName   = pFc.AliasName;
                            pResAttr.Add(pResInfo);
                        }
                        else
                        {
                            pHtable.Add(bsm, (pFc as IDataset).Name);
                        }
                    }
                    Marshal.ReleaseComObject(pFeatCur);
                }
                pEmDs = m_BaseWorkspace.get_Datasets(esriDatasetType.esriDTFeatureDataset);
                while ((pDt = pEmDs.Next()) != null)
                {
                    IEnumDataset subEnumDs = pDt.Subsets;
                    IDataset     pSubDt    = null;
                    while ((pSubDt = subEnumDs.Next()) != null)
                    {
                        IFeatureClass pFc = pSubDt as IFeatureClass;

                        if (pFc.AliasName == "注记" || pFc.AliasName.Equals("ZJ", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        int bsmFieldIndex = pFc.FindField("bsm");
                        if (bsmFieldIndex == -1)
                        {
                            continue;
                        }

                        pQueryFilter.SubFields = pFc.OIDFieldName + ",bsm";
                        IFeatureCursor pFeatCur = pFc.Search(pQueryFilter, false);
                        bsmFieldIndex = pFeatCur.FindField("bsm");
                        if (bsmFieldIndex == -1)
                        {
                            continue;
                        }
                        IFeature pFeat = null;
                        while ((pFeat = pFeatCur.NextFeature()) != null)
                        {
                            string bsm = pFeat.get_Value(bsmFieldIndex).ToString();
                            if (pHtable.Contains(bsm))
                            {
                                Error pResInfo = new Error();
                                pResInfo.DefectLevel = this.m_DefectLevel;
                                pResInfo.RuleID      = this.InstanceID;

                                pResInfo.OID         = pFeat.OID;
                                pResInfo.BSM         = bsm;
                                pResInfo.Description = string.Format(Helper.ErrMsgFormat.ERR_630100001, pFc.AliasName, pHtable[bsm].ToString(), bsm);
                                pResInfo.LayerName   = pFc.AliasName;//(pFc as IDataset).Name;
                                pResAttr.Add(pResInfo);
                            }
                            else
                            {
                                pHtable.Add(bsm, (pFc as IDataset).Name);
                            }
                        }
                        Marshal.ReleaseComObject(pFeatCur);
                    }
                }
                pHtable.Clear();
                Marshal.ReleaseComObject(pQueryFilter);
                checkResult = pResAttr;

                return(true);
            }
            catch (Exception ex)
            {
                SendMessage(enumMessageType.Exception, ex.ToString());
                return(false);
            }
        }
示例#25
0
        private void btnAnalysis_Click(object obj, EventArgs eventArgs)
        {
            if (cmbDepthType.SelectedIndex < 0)
            {
                MessageService.Current.Warn("请先选择埋深数据类型再进行分析!");
                return;
            }
            this.gridView1.Columns.Clear();
            //this.gridControl1.DataRowCount=0;//.Rows.Clear();
            IQueryFilter queryFilter = null;
            bool         isM         = cmbDepthType.SelectedIndex > 0 ? true : false;

            if (chkRegionAnalysis.Checked)
            {
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                spatialFilter.Geometry   = _context.ActiveView.Extent;
                spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                queryFilter = spatialFilter as IQueryFilter;
            }
            _table = null;
            foreach (CheckListFeatureLayerItem pclass in this.checkedListBox1.CheckedItems)
            {
                IFeatureLayer ifeatureLayer = pclass.m_pFeatureLayer;
                this.progressBar1.Visible = true;
                this.progressBar1.Maximum = ifeatureLayer.FeatureClass.FeatureCount(queryFilter);
                this.progressBar1.Step    = 1;
                this.progressBar1.Value   = 0;
                this.Text = "覆土分析 - 正在处理:" + ifeatureLayer.Name + "...";
                IPipelineLayer  pipelineLayer = _config.GetPipelineLayer(ifeatureLayer.FeatureClass);
                IBasicLayerInfo pipeLine      = _config.GetBasicLayerInfo(ifeatureLayer.FeatureClass) as IBasicLayerInfo;


                string lineConfig_Kind = pipelineLayer.Code;

                string sDepthMethod = "";
                string sDepPosition = "";
                int    num          =
                    ifeatureLayer.FeatureClass.Fields.FindField(
                        pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.MSFS));
                //基本上没有使用,因为所在位置没有数据
                int num2 =
                    ifeatureLayer.FeatureClass.Fields.FindField(
                        pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.SZWZ));
                IFeatureCursor featureCursor = ifeatureLayer.Search(queryFilter, false);
                int            qdmsIdx       = featureCursor.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.QDMS));
                int            zdmsIdx       = featureCursor.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.ZDMS));

                BuildTable(featureCursor);
                IFeature feature = featureCursor.NextFeature();
                while (feature != null)
                {
                    this.progressBar1.Value = this.progressBar1.Value + 1;
                    if (feature.Shape == null || feature.Shape.GeometryType != esriGeometryType.esriGeometryPolyline)
                    {
                        feature = featureCursor.NextFeature();
                    }
                    else
                    {
                        if (num != -1)
                        {
                            sDepthMethod = feature.get_Value(num).ToString();
                        }
                        if (num2 != -1)
                        {
                            sDepPosition = feature.get_Value(num2).ToString();
                        }
                        double ruleMS = this.m_RuleMs.GetRuleMS(lineConfig_Kind, sDepthMethod, sDepPosition);
                        if (isM)
                        {
                            IPoint point  = ((IPointCollection)feature.Shape).get_Point(0);
                            IPoint point2 = ((IPointCollection)feature.Shape).get_Point(1);
                            if (point.M < ruleMS || point2.M < ruleMS)
                            {
                                this.FillFeatureValue(pipeLine, lineConfig_Kind, feature, ruleMS, point.M, point2.M);
                            }
                        }
                        else
                        {
                            double qdms = qdmsIdx >= 0 ? Convert.ToDouble(feature.Value[qdmsIdx]) : 0;
                            double zdms = qdmsIdx >= 0 ? Convert.ToDouble(feature.Value[zdmsIdx]) : 0;
                            if (qdms < ruleMS || zdms < ruleMS)
                            {
                                this.FillFeatureValue(pipeLine, lineConfig_Kind, feature, ruleMS, qdms, zdms);
                            }
                        }
                        feature = featureCursor.NextFeature();
                    }
                }
                Marshal.ReleaseComObject(featureCursor);
                this.progressBar1.Visible    = false;
                this.gridControl1.DataSource = _table;
            }
            this.Text = "覆土分析--记录数:" + _table.Rows.Count.ToString();
        }
示例#26
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            try
            {
                string strLayerName  = cboTargetLayer.Text;
                string strIDFldName  = cboFieldName.Text;
                string strOutputName = txtOutput.Text;
                bool   blnRook       = true;

                if (strLayerName == "" || strIDFldName == "" || strOutputName == "")
                {
                    MessageBox.Show("Please select layer or fields");
                    return;
                }
                clsSnippet pSnippet  = new clsSnippet();
                int        intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strLayerName);
                ILayer     pLayer    = mForm.axMapControl1.get_Layer(intLIndex);

                IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                ESRI.ArcGIS.Geodatabase.IFeatureClass pFClass = pFLayer.FeatureClass;

                IFields        fields   = pFClass.Fields;
                IFeatureCursor pFCursor = pFClass.Search(null, false);

                IFeature pFeature = pFCursor.NextFeature();
                int      intIDIdx = pFCursor.FindField(strIDFldName);

                ISpatialFilter pSF = new SpatialFilterClass();


                IFeatureCursor pNBCursor  = null;
                IFeature       pNBFeature = null;
                int            NBNumber   = 0;
                string         strNBIDs   = null;

                ITopologicalOperator pTopoOp = (ITopologicalOperator)pFeature.Shape;
                pSF.Geometry   = pFeature.ShapeCopy;
                pSF.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                IPointCollection pPointCol;

                System.IO.StreamWriter pSW = new System.IO.StreamWriter(strOutputName);
                pSW.WriteLine("0 " + pFClass.FeatureCount(null).ToString() + " " + pFClass.AliasName + " " + strIDFldName);


                while (pFeature != null)
                {
                    NBNumber = 0;
                    strNBIDs = null;

                    pSF.Geometry   = pFeature.ShapeCopy;
                    pSF.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects;

                    pNBCursor  = pFClass.Search(pSF, true);
                    pNBFeature = pNBCursor.NextFeature();

                    while (pNBFeature != null)
                    {
                        if (pFeature.get_Value(intIDIdx).Equals(pNBFeature.get_Value(intIDIdx)))
                        {
                            //if(pFeature.get_Value(intIDIdx) == pNBFeature.get_Value(intIDIdx))
                            pNBFeature = pNBCursor.NextFeature();
                        }
                        else
                        {
                            NBNumber  = NBNumber + 1;
                            pPointCol = (IPointCollection)pTopoOp.Intersect(pNBFeature.Shape, esriGeometryDimension.esriGeometry0Dimension);
                            if (blnRook)
                            {
                                if (pPointCol.PointCount != 1)
                                {
                                    strNBIDs = strNBIDs + " " + pNBFeature.get_Value(intIDIdx);
                                }
                                else
                                {
                                    NBNumber -= 1;
                                }
                            }
                            else
                            {
                                strNBIDs = strNBIDs + " " + pNBFeature.get_Value(intIDIdx);
                            }

                            pNBFeature = pNBCursor.NextFeature();
                        }
                    }

                    pNBCursor.Flush();

                    if (NBNumber > 0)
                    {
                        pSW.WriteLine(pFeature.get_Value(intIDIdx).ToString() + " " + NBNumber.ToString());
                        pSW.WriteLine(strNBIDs.Substring(1));
                    }
                    else
                    {
                        pSW.WriteLine(pFeature.get_Value(intIDIdx).ToString() + " " + NBNumber.ToString());
                        pSW.WriteLine("");
                    }

                    pFeature = pFCursor.NextFeature();
                }

                pSW.Close();
                pSW.Dispose();

                MessageBox.Show(strOutputName + " is generated.");
                //this.Close();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#27
0
        public void ApplyBarChartValue(IGeoFeatureLayer geoLayer, string aFieldName)
        {
            //IChartRender is engaged with feature data
            IChartRenderer  chartRender  = new ChartRenderer();
            IRendererFields renderFields = chartRender as IRendererFields;

            renderFields.AddField(aFieldName);
            //Search Max
            IQueryFilter queryFilter = new QueryFilter();

            //Content in Cursor
            queryFilter.AddField(aFieldName);
            //Search all features without WhereClause
            IFeatureCursor fCursor = geoLayer.FeatureClass.Search(queryFilter, true);
            //the index of Field
            int           indexField = fCursor.FindField(aFieldName);
            List <double> valueList  = new List <double>();
            IFeature      aFeature   = fCursor.NextFeature();

            while (aFeature != null)
            {
                valueList.Add(Convert.ToDouble(aFeature.get_Value(indexField)));
                aFeature = fCursor.NextFeature();
            }
            //BarChartSymbol
            IBarChartSymbol barSymbol = new BarChartSymbol() as IBarChartSymbol;

            barSymbol.Width = 12;
            IChartSymbol chartSym = barSymbol as IChartSymbol;

            //
            chartSym.MaxValue = valueList.Max();
            IMarkerSymbol markerSymbol = (IMarkerSymbol)chartSym;

            markerSymbol.Size = 50;
            //Set Symbol
            ISymbolArray pSymbolArray = (ISymbolArray)barSymbol;
            IRgbColor    aColor       = new RgbColor();

            aColor.Red   = Convert.ToInt32(255);
            aColor.Green = Convert.ToInt32(255);
            aColor.Blue  = Convert.ToInt32(0);
            ISimpleFillSymbol pFillSymbol = new SimpleFillSymbol();

            pFillSymbol.Color = aColor;
            pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

            //Render Attribute
            chartRender.ChartSymbol   = (IChartSymbol)barSymbol;
            chartRender.Label         = "指标";
            chartRender.UseOverposter = false;
            chartRender.CreateLegend();

            //Back Ground
            ISimpleFillSymbol bgSym   = new SimpleFillSymbol();
            IRgbColor         bgColor = new RgbColor();

            bgColor.Red   = Convert.ToInt32(239);
            bgColor.Green = Convert.ToInt32(228);
            bgColor.Blue  = Convert.ToInt32(190);
            bgSym.Color   = bgColor;
            //bgSym.Color = Convert.ToInt32(System.Drawing.Color.FromArgb(239, 228, 190));
            chartRender.BaseSymbol = (ISymbol)bgSym;

            //Render Label
            geoLayer.ScaleSymbols = true;
            //Scale Symbol
            geoLayer.Renderer = chartRender as IFeatureRenderer;
            axMapControl1.ActiveView.Refresh();
            axTOCControl1.Update();
        }