예제 #1
0
        private void initialClassify()
        {
            if (layer2Symbolize == null)
            {
                return;
            }
            IFeatureClass   featureClass    = layer2Symbolize.FeatureClass;
            ITable          pTable          = (ITable)featureClass;
            ITableHistogram pTableHistogram = new BasicTableHistogramClass();
            IBasicHistogram pHistogram      = (IBasicHistogram)pTableHistogram;

            pTableHistogram.Field = strRendererField;
            if (strNormalizeField.ToLower() != "none")
            {
                pTableHistogram.NormField = strNormalizeField;
            }
            pTableHistogram.Table = pTable;
            object dataFrequency;
            object dataValues;

            pHistogram.GetHistogram(out dataValues, out dataFrequency);

            IClassifyGEN pClassify         = null;
            int          numDesiredClasses = classCount;

            pClassify = new EqualIntervalClass();
            pClassify.Classify(dataValues, dataFrequency, ref numDesiredClasses);
            double[] clsbreaks   = (double[])pClassify.ClassBreaks;
            double   dblInterval = clsbreaks[1] - clsbreaks[0];

            txtInterval.Text = dblInterval.ToString();
        }
예제 #2
0
        private void classify()
        {
            if (layer2Symbolize == null)
            {
                return;
            }
            IFeatureClass featureClass = layer2Symbolize.FeatureClass;
            ITable        pTable       = (ITable)featureClass;

            ITableHistogram pTableHistogram = new BasicTableHistogramClass();
            IBasicHistogram pHistogram      = (IBasicHistogram)pTableHistogram;

            pTableHistogram.Field = strRendererField;
            if (strNormalizeField.ToLower() != "none")
            {
                pTableHistogram.NormField = strNormalizeField;
            }
            pTableHistogram.Table = pTable;
            object dataFrequency;
            object dataValues;

            pHistogram.GetHistogram(out dataValues, out dataFrequency);
            //下面是分级方法,用于根据获得的值计算得出符合要求的数据
            //根据条件计算出Classes和ClassesCount,numDesiredClasses为预定的分级数目
            IClassifyGEN pClassify = new NaturalBreaksClass();

            switch (strClassifyMethod)
            {
            case "等间隔分类":
                pClassify = new EqualIntervalClass();
                break;

            //case "预定义间隔分类":
            //    pClassify = new DefinedIntervalClass();
            //    break;
            case "分位数分类":
                pClassify = new QuantileClass();
                break;

            case "自然裂点分类":
                pClassify = new NaturalBreaksClass();
                break;

            case "标准差分类":
                pClassify = new StandardDeviationClass();
                break;

            case "几何间隔分类":
                pClassify = new GeometricalIntervalClass();
                break;

            default:
                break;
            }
            int numDesiredClasses = gClassCount;

            pClassify.Classify(dataValues, dataFrequency, ref numDesiredClasses);
            gClassbreaks = (double[])pClassify.ClassBreaks;
        }
예제 #3
0
        private double[] fnClassification(IFeatureLayer pFLayer, decimal NClasses, string strClassifiedField, string ClassifiedMethod)
        {
            try
            {
                IFeatureClass pFClass = pFLayer.FeatureClass;

                //Create Rendering of Mean Value at Target Layer
                int intBreakeCount = Convert.ToInt32(NClasses);

                ITable       pTable = (ITable)pFClass;
                IClassifyGEN pClassifyGEN;
                switch (ClassifiedMethod)
                {
                case "Equal Interval":
                    pClassifyGEN = new EqualIntervalClass();
                    break;

                case "Geometrical Interval":
                    pClassifyGEN = new GeometricalInterval();
                    break;

                case "Natural Breaks":
                    pClassifyGEN = new NaturalBreaksClass();
                    break;

                case "Quantile":
                    pClassifyGEN = new QuantileClass();
                    break;

                case "StandardDeviation":
                    pClassifyGEN = new StandardDeviationClass();
                    break;

                default:
                    pClassifyGEN = new NaturalBreaksClass();
                    break;
                }

                //Need to be changed 1/29/15
                ITableHistogram pTableHistogram = new BasicTableHistogramClass();
                pTableHistogram.Field = strClassifiedField;
                pTableHistogram.Table = pTable;
                IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram;

                object xVals, frqs;
                pHistogram.GetHistogram(out xVals, out frqs);
                pClassifyGEN.Classify(xVals, frqs, intBreakeCount);
                double[] cb = (double[])pClassifyGEN.ClassBreaks;

                return(cb);
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return(null);
            }
        }
예제 #4
0
        private void classify()
        {
            if (layer2Symbolize == null)
            {
                return;
            }
            IFeatureClass   featureClass    = layer2Symbolize.FeatureClass;
            ITable          pTable          = featureClass as ITable;
            ITableHistogram pTableHistogram = new BasicTableHistogramClass();
            IBasicHistogram pHistogram      = pTableHistogram as IBasicHistogram;

            pTableHistogram.Field = strRendererField;
            if (strNormalizeField.ToLower() != "none")
            {
                pTableHistogram.NormField = strNormalizeField;
            }
            pTableHistogram.Table = pTable;
            object dataFrequency;
            object dataValues;

            pHistogram.GetHistogram(out dataValues, out dataFrequency);
            IClassifyGEN pClassify = new NaturalBreaksClass();

            switch (strClassifyMethod)
            {
            case "Equal Interval":
                pClassify = new EqualIntervalClass();
                break;

            case "Quantile":
                pClassify = new QuantileClass();
                break;

            case "Natural Breaks":
                pClassify = new NaturalBreaksClass();
                break;

            case "Geometrical Interval":
                pClassify = new GeometricalIntervalClass();
                break;

            default:
                break;
            }
            int numDesiredClass = gClassCount;

            pClassify.Classify(dataValues, dataFrequency, ref numDesiredClass);
            gClassbreaks = (double[])pClassify.ClassBreaks;
        }
예제 #5
0
        private IClassBreaksRenderer CreateClassBreaksRenderer(IFeatureClass featureClass, string breakMethod)
        {
            ITable pTable = (ITable)featureClass;

            //从pTable的strRendererField字段中得到信息给datavalues和datafrequency两个数组
            ITableHistogram pTableHistogram = new BasicTableHistogramClass();
            IBasicHistogram pHistogram      = (IBasicHistogram)pTableHistogram;

            pTableHistogram.Field = strRendererField;
            if (strNormalizeField.ToLower() != "none")
            {
                pTableHistogram.NormField = strNormalizeField;
            }
            pTableHistogram.Table = pTable;
            object dataFrequency;
            object dataValues;

            pHistogram.GetHistogram(out dataValues, out dataFrequency);

            //下面是分级方法,用于根据获得的值计算得出符合要求的数据
            //根据条件计算出Classes和ClassesCount,numDesiredClasses为预定的分级数目
            IClassifyGEN pClassify         = null;
            int          numDesiredClasses = classCount;

            switch (breakMethod)
            {
            case "等间隔":
                pClassify = new EqualIntervalClass();
                break;

            case "已定义的间隔":
                pClassify = new DefinedIntervalClass();
                IIntervalRange2 intervalRange = pClassify as IIntervalRange2;
                intervalRange.IntervalRange = dblDefinedInterval;
                break;

            case "分位数":
                pClassify = new QuantileClass();
                break;

            case "自然裂点":
                pClassify = new NaturalBreaksClass();
                break;

            case "标准差":
                pClassify = new StandardDeviationClass();
                IStatisticsResults pStatRes = pHistogram as IStatisticsResults;
                IDeviationInterval pStdDev  = pClassify as IDeviationInterval;
                pStdDev.Mean              = pStatRes.Mean;
                pStdDev.StandardDev       = pStatRes.StandardDeviation;
                pStdDev.DeviationInterval = dblStdDevInterval;
                break;

            default:
                break;
            }

            if (pClassify == null)
            {
                return(null);
            }
            pClassify.Classify(dataValues, dataFrequency, ref numDesiredClasses);
            //返回一个数组
            double[] classBreaks  = (double[])pClassify.ClassBreaks;
            int      ClassesCount = classBreaks.GetUpperBound(0);

            nudClassCount.Value = ClassesCount;
            IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();

            pClassBreaksRenderer.Field = strRendererField;
            if (strNormalizeField.ToLower() != "none")
            {
                pClassBreaksRenderer.NormField = strNormalizeField;
            }
            //设置着色对象的分级数目
            pClassBreaksRenderer.BreakCount           = ClassesCount;
            pClassBreaksRenderer.SortClassesAscending = true;
            if (colorRamp == null)
            {
                MessageBox.Show("请先选择色带!!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(null);
            }
            //通过色带设置各级分类符号的颜色
            colorRamp.Size = ClassesCount;
            bool createRamp;

            colorRamp.CreateRamp(out createRamp);
            IEnumColors enumColors = colorRamp.Colors;

            enumColors.Reset();
            IColor  pColor = null;
            ISymbol symbol = null;

            if (gloabalSymbol == null)
            {
                MessageBox.Show("请选择符号...", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(null);
            }
            //需要注意的是分级着色对象中的symbol和break的下标都是从0开始
            for (int i = 0; i < ClassesCount; i++)
            {
                pColor = enumColors.Next();
                switch (featureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    IMarkerSymbol markerSymbol = gloabalSymbol as IMarkerSymbol;
                    markerSymbol.Color = pColor;
                    symbol             = markerSymbol as ISymbol;
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    ILineSymbol lineSymbol = gloabalSymbol as ILineSymbol;
                    lineSymbol.Color = pColor;
                    symbol           = lineSymbol as ISymbol;
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    IFillSymbol fillSymbol = gloabalSymbol as IFillSymbol;
                    fillSymbol.Color = pColor;
                    symbol           = fillSymbol as ISymbol;
                    break;

                default:
                    break;
                }
                pClassBreaksRenderer.set_Symbol(i, symbol);
                pClassBreaksRenderer.set_Break(i, classBreaks[i + 1]);
            }
            return(pClassBreaksRenderer);
        }
예제 #6
0
        /// <summary>
        /// Class Break Render
        /// </summary>
        /// <param name="currentLayer"></param>
        /// <param name="breakCount"></param>
        /// <author>Shen Yongyuan</author>
        /// <date>20091114</date>
        public static void ClassBreakRender(ILayer currentLayer, int breakCount, string fieldName, ref double[] Classes, ref int[] Colors, bool reverse)
        {
            //Get All Value
            object          dataFrequency   = null;
            object          dataValues      = null;
            ITableHistogram pTableHistogram = new BasicTableHistogramClass();
            IBasicHistogram pHistogram      = (IBasicHistogram)pTableHistogram;

            pTableHistogram.Field = fieldName;
            pTableHistogram.Table = (currentLayer as IGeoFeatureLayer).DisplayFeatureClass as ITable;
            pHistogram.GetHistogram(out dataValues, out dataFrequency);

            //Class
            IClassifyGEN pClassify = new EqualIntervalClass();

            pClassify.Classify(dataValues, dataFrequency, ref breakCount);

            //Set Class Breaks
            Classes = (double[])pClassify.ClassBreaks;
            int ClassesCount = Classes.GetUpperBound(0);
            IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();

            pClassBreaksRenderer.Field = fieldName;

            //Set From to Color
            IHsvColor pFromColor = new HsvColorClass();

            pFromColor.Hue        = reverse ? 105 : 353;
            pFromColor.Saturation = reverse ? 46 : 56;
            pFromColor.Value      = reverse ? 76 : 92;
            IHsvColor pToColor = new HsvColorClass();

            pToColor.Hue        = reverse ? 353 : 105;
            pToColor.Saturation = reverse ? 56 : 46;
            pToColor.Value      = reverse ? 92 : 76;

            //Get Color
            IAlgorithmicColorRamp pAlgorithmicCR = new AlgorithmicColorRampClass();

            pAlgorithmicCR.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            pAlgorithmicCR.FromColor = pFromColor;
            pAlgorithmicCR.ToColor   = pToColor;
            pAlgorithmicCR.Size      = ClassesCount;
            bool ok = false;

            pAlgorithmicCR.CreateRamp(out ok);
            IEnumColors pEnumColors = pAlgorithmicCR.Colors;

            //Set Break Count
            pClassBreaksRenderer.BreakCount           = ClassesCount;
            pClassBreaksRenderer.SortClassesAscending = true;

            //Set Break Interval
            for (int lbreakIndex = 0; lbreakIndex <= ClassesCount - 1; lbreakIndex++)
            {
                IColor pColor = pEnumColors.Next();
                Colors[lbreakIndex] = pColor.RGB;
                ISimpleFillSymbol pSimpleFillS = new SimpleFillSymbolClass();
                pSimpleFillS.Color = pColor;
                pSimpleFillS.Style = esriSimpleFillStyle.esriSFSSolid;
                pClassBreaksRenderer.set_Symbol(lbreakIndex, (ISymbol)pSimpleFillS);
                pClassBreaksRenderer.set_Break(lbreakIndex, Classes[lbreakIndex + 1]);
            }

            //Set Render
            (currentLayer as IGeoFeatureLayer).Renderer = pClassBreaksRenderer as IFeatureRenderer;
        }
예제 #7
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboSourceLayer.Text;
                if (cboSourceLayer.Text == "" || cboValueField.Text == "" || cboUField.Text == "")
                {
                    MessageBox.Show("Assign proper layer and field");
                    return;
                }

                int    intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strLayerName);
                ILayer pLayer    = mForm.axMapControl1.get_Layer(intLIndex);

                IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                IFeatureClass pFClass = pFLayer.FeatureClass;

                //Create Rendering of Mean Value at Target Layer
                int    intGCBreakeCount = Convert.ToInt32(nudGCNClasses.Value);
                string strGCRenderField = cboValueField.Text;

                IGeoFeatureLayer pGeofeatureLayer;
                if (chkNewLayer.Checked == true)
                {
                    IFeatureLayer pflOutput = new FeatureLayerClass();
                    pflOutput.FeatureClass = pFClass;
                    pflOutput.Name         = txtNewLayer.Text;
                    pflOutput.Visible      = true;

                    pGeofeatureLayer = (IGeoFeatureLayer)pflOutput;
                }
                else
                {
                    pGeofeatureLayer = (IGeoFeatureLayer)pFLayer;
                }

                ITable       pTable = (ITable)pFClass;
                IClassifyGEN pClassifyGEN;
                switch (cboGCClassify.Text)
                {
                case "Equal Interval":
                    pClassifyGEN = new EqualIntervalClass();
                    break;

                case "Geometrical Interval":
                    pClassifyGEN = new GeometricalInterval();
                    break;

                case "Natural Breaks":
                    pClassifyGEN = new NaturalBreaksClass();
                    break;

                case "Quantile":
                    pClassifyGEN = new QuantileClass();
                    break;

                case "StandardDeviation":
                    pClassifyGEN = new StandardDeviationClass();
                    break;

                default:
                    pClassifyGEN = new NaturalBreaksClass();
                    break;
                }

                //Need to be changed 1/29/15
                ITableHistogram pTableHistogram = new BasicTableHistogramClass();
                pTableHistogram.Field = strGCRenderField;
                pTableHistogram.Table = pTable;
                IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram;

                object xVals, frqs;
                pHistogram.GetHistogram(out xVals, out frqs);
                pClassifyGEN.Classify(xVals, frqs, intGCBreakeCount);

                ClassBreaksRenderer pRender = new ClassBreaksRenderer();
                double[]            cb      = (double[])pClassifyGEN.ClassBreaks;
                pRender.Field        = strGCRenderField;
                pRender.BreakCount   = intGCBreakeCount;
                pRender.MinimumBreak = cb[0];

                //' create our color ramp
                IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();
                pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                IRgbColor pColor1 = new RgbColor();
                IRgbColor pColor2 = new RgbColor();

                //Can Change the color in here!
                pColor1.Red   = picSymolfrom.BackColor.R;
                pColor1.Green = picSymolfrom.BackColor.G;
                pColor1.Blue  = picSymolfrom.BackColor.B;

                Boolean blnOK = true;
                pColor2.Red          = picSymbolTo.BackColor.R;
                pColor2.Green        = picSymbolTo.BackColor.G;
                pColor2.Blue         = picSymbolTo.BackColor.B;
                pColorRamp.FromColor = pColor1;
                pColorRamp.ToColor   = pColor2;
                pColorRamp.Size      = intGCBreakeCount;
                pColorRamp.CreateRamp(out blnOK);

                IEnumColors pEnumColors = pColorRamp.Colors;
                pEnumColors.Reset();

                IRgbColor pColorOutline = new RgbColor();
                //Can Change the color in here!
                pColorOutline.Red   = picGCLineColor.BackColor.R;
                pColorOutline.Green = picGCLineColor.BackColor.G;
                pColorOutline.Blue  = picGCLineColor.BackColor.B;
                double dblGCOutlineSize = Convert.ToDouble(nudGCLinewidth.Value);

                ICartographicLineSymbol pOutLines = new CartographicLineSymbol();
                pOutLines.Width = dblGCOutlineSize;
                pOutLines.Color = (IColor)pColorOutline;

                //' use this interface to set dialog properties
                IClassBreaksUIProperties pUIProperties = (IClassBreaksUIProperties)pRender;
                pUIProperties.ColorRamp = "Custom";

                ISimpleFillSymbol pSimpleFillSym;
                //' be careful, indices are different for the diff lists
                for (int j = 0; j < intGCBreakeCount; j++)
                {
                    pRender.Break[j]          = cb[j + 1];
                    pRender.Label[j]          = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString();
                    pUIProperties.LowBreak[j] = cb[j];
                    pSimpleFillSym            = new SimpleFillSymbolClass();
                    pSimpleFillSym.Color      = pEnumColors.Next();
                    pSimpleFillSym.Outline    = pOutLines;
                    pRender.Symbol[j]         = (ISymbol)pSimpleFillSym;
                }
                pGeofeatureLayer.Renderer = (IFeatureRenderer)pRender;
                if (chkNewLayer.Checked == true)
                {
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                }



                ////* Uncertainty Part *////
                //Declare variables in if parts

                if (tcUncern.SelectedIndex == 0) //Graduated Color
                {
                    int    intUncernBreakCount = Convert.ToInt32(nudCoNClasses.Value);
                    string strUncerFieldName   = cboUField.Text;

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    switch (cboTeClassify.Text)
                    {
                    case "Equal Interval":
                        pClassifyGEN = new EqualIntervalClass();
                        break;

                    case "Geometrical Interval":
                        pClassifyGEN = new GeometricalInterval();
                        break;

                    case "Natural Breaks":
                        pClassifyGEN = new NaturalBreaksClass();
                        break;

                    case "Quantile":
                        pClassifyGEN = new QuantileClass();
                        break;

                    case "StandardDeviation":
                        pClassifyGEN = new StandardDeviationClass();
                        break;

                    default:
                        pClassifyGEN = new NaturalBreaksClass();
                        break;
                    }
                    //Need to be changed 1/29/15
                    pTableHistogram       = new BasicTableHistogramClass();
                    pTableHistogram.Field = strUncerFieldName;
                    pTableHistogram.Table = pTable;
                    pHistogram            = (IBasicHistogram)pTableHistogram;

                    pHistogram.GetHistogram(out xVals, out frqs);
                    pClassifyGEN.Classify(xVals, frqs, intUncernBreakCount);

                    pRender              = new ClassBreaksRenderer();
                    cb                   = (double[])pClassifyGEN.ClassBreaks;
                    pRender.Field        = strUncerFieldName;
                    pRender.BreakCount   = intUncernBreakCount;
                    pRender.MinimumBreak = cb[0];

                    IClassBreaksUIProperties pUIColProperties = (IClassBreaksUIProperties)pRender;
                    pUIColProperties.ColorRamp = "Custom";

                    pColorRamp           = new AlgorithmicColorRampClass();
                    pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                    pColor1 = new RgbColor();
                    pColor2 = new RgbColor();

                    //Can Change the color in here!
                    pColor1 = pSnippet.getRGB(picCoColorFrom.BackColor.R, picCoColorFrom.BackColor.G, picCoColorFrom.BackColor.B);
                    pColor2 = pSnippet.getRGB(picCoColorTo.BackColor.R, picCoColorTo.BackColor.G, picCoColorTo.BackColor.B);
                    if (pColor1 == null || pColor2 == null)
                    {
                        return;
                    }

                    blnOK = true;
                    pColorRamp.FromColor = pColor1;
                    pColorRamp.ToColor   = pColor2;
                    pColorRamp.Size      = intUncernBreakCount;
                    pColorRamp.CreateRamp(out blnOK);

                    pEnumColors = pColorRamp.Colors;
                    pEnumColors.Reset();

                    pColorOutline = pSnippet.getRGB(picCoLineColor.BackColor.R, picCoLineColor.BackColor.G, picCoLineColor.BackColor.B);
                    if (pColorOutline == null)
                    {
                        return;
                    }

                    double dblCoOutlineSize = Convert.ToDouble(nudCoLinewidth.Value);

                    pOutLines       = new CartographicLineSymbol();
                    pOutLines.Width = dblCoOutlineSize;
                    pOutLines.Color = (IColor)pColorOutline;

                    //' use this interface to set dialog properties
                    pUIColProperties           = (IClassBreaksUIProperties)pRender;
                    pUIColProperties.ColorRamp = "Custom";

                    ISimpleMarkerSymbol pSimpleMarkerSym;
                    double dblCoSymSize = Convert.ToDouble(nudCoSymbolSize.Value);
                    //' be careful, indices are different for the diff lists
                    for (int j = 0; j < intUncernBreakCount; j++)
                    {
                        pRender.Break[j]              = cb[j + 1];
                        pRender.Label[j]              = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString();
                        pUIColProperties.LowBreak[j]  = cb[j];
                        pSimpleMarkerSym              = new SimpleMarkerSymbolClass();
                        pSimpleMarkerSym.Size         = dblCoSymSize;
                        pSimpleMarkerSym.Color        = pEnumColors.Next();
                        pSimpleMarkerSym.Outline      = true;
                        pSimpleMarkerSym.OutlineColor = pColorOutline;
                        pSimpleMarkerSym.OutlineSize  = dblCoOutlineSize;
                        pRender.Symbol[j]             = (ISymbol)pSimpleMarkerSym;
                    }

                    pGFLUncern.Renderer = (IFeatureRenderer)pRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 1) //Texture
                {
                    //Create Rendering of Uncertainty at Target Layer
                    int    intUncernBreakCount = Convert.ToInt32(nudTeNClasses.Value);
                    string strUncerFieldName   = cboUField.Text;

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    switch (cboTeClassify.Text)
                    {
                    case "Equal Interval":
                        pClassifyGEN = new EqualIntervalClass();
                        break;

                    case "Geometrical Interval":
                        pClassifyGEN = new GeometricalInterval();
                        break;

                    case "Natural Breaks":
                        pClassifyGEN = new NaturalBreaksClass();
                        break;

                    case "Quantile":
                        pClassifyGEN = new QuantileClass();
                        break;

                    case "StandardDeviation":
                        pClassifyGEN = new StandardDeviationClass();
                        break;

                    default:
                        pClassifyGEN = new NaturalBreaksClass();
                        break;
                    }
                    //Need to be changed 1/29/15
                    pTableHistogram       = new BasicTableHistogramClass();
                    pTableHistogram.Field = strUncerFieldName;
                    pTableHistogram.Table = pTable;
                    pHistogram            = (IBasicHistogram)pTableHistogram;

                    pHistogram.GetHistogram(out xVals, out frqs);
                    pClassifyGEN.Classify(xVals, frqs, intUncernBreakCount);

                    pRender              = new ClassBreaksRenderer();
                    cb                   = (double[])pClassifyGEN.ClassBreaks;
                    pRender.Field        = strUncerFieldName;
                    pRender.BreakCount   = intUncernBreakCount;
                    pRender.MinimumBreak = cb[0];

                    IClassBreaksUIProperties pUITexProperties = (IClassBreaksUIProperties)pRender;
                    pUITexProperties.ColorRamp = "Custom";

                    ILineFillSymbol pLineFillSym    = new LineFillSymbolClass();
                    double          dblFromSep      = Convert.ToDouble(nudSeperationFrom.Value);
                    double          dblToSep        = Convert.ToDouble(nudSeperationTo.Value);
                    double          dblInstantSep   = (dblFromSep - dblToSep) / Convert.ToDouble(intUncernBreakCount - 1);
                    double          dblFromAngle    = Convert.ToDouble(nudAngleFrom.Value);
                    double          dblToAngle      = Convert.ToDouble(nudAngleFrom.Value); // Remove the angle part (04/16)
                    double          dblInstantAngle = (dblToAngle - dblFromAngle) / Convert.ToDouble(intUncernBreakCount - 1);
                    double          dblLinewidth    = Convert.ToDouble(nudTeLinewidth.Value);
                    IRgbColor       pLineColor      = new RgbColor();
                    pLineColor.Red   = picTeLineColor.BackColor.R;
                    pLineColor.Green = picTeLineColor.BackColor.G;
                    pLineColor.Blue  = picTeLineColor.BackColor.B;

                    //' be careful, indices are different for the diff lists
                    for (int j = 0; j < intUncernBreakCount; j++)
                    {
                        pRender.Break[j]             = cb[j + 1];
                        pRender.Label[j]             = Math.Round(cb[j], 5).ToString() + " - " + Math.Round(cb[j + 1], 5).ToString();
                        pUITexProperties.LowBreak[j] = cb[j];
                        pLineFillSym                  = new LineFillSymbolClass();
                        pLineFillSym.Angle            = dblFromAngle + (dblInstantAngle * Convert.ToDouble(j));
                        pLineFillSym.Color            = pLineColor;
                        pLineFillSym.Separation       = dblFromSep - (dblInstantSep * Convert.ToDouble(j));
                        pLineFillSym.LineSymbol.Width = dblLinewidth;
                        pRender.Symbol[j]             = (ISymbol)pLineFillSym;
                    }
                    pGFLUncern.Renderer = (IFeatureRenderer)pRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 2) //For Proportional Symbols
                {
                    string strUncerFieldName = cboUField.Text;
                    double dblMinPtSize      = Convert.ToDouble(nudProSymbolSize.Value);
                    double dblLineWidth      = Convert.ToDouble(nudProLinewidth.Value);

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    //Find Fields
                    int intUncernIdx = pTable.FindField(strUncerFieldName);

                    //Find Min value
                    //Set to initial value for min
                    IField          pUncernField = pTable.Fields.get_Field(intUncernIdx);
                    ICursor         pCursor      = pTable.Search(null, false);
                    IDataStatistics pDataStat    = new DataStatisticsClass();
                    pDataStat.Field  = pUncernField.Name;
                    pDataStat.Cursor = pCursor;
                    IStatisticsResults pStatResults = pDataStat.Statistics;
                    double             dblMinValue  = pStatResults.Minimum;
                    double             dblMaxValue  = pStatResults.Maximum;
                    pCursor.Flush();


                    IRgbColor pSymbolRgb = pSnippet.getRGB(picProSymbolColor.BackColor.R, picProSymbolColor.BackColor.G, picProSymbolColor.BackColor.B);
                    if (pSymbolRgb == null)
                    {
                        return;
                    }

                    IRgbColor pLineRgb = pSnippet.getRGB(picProiLineColor.BackColor.R, picProiLineColor.BackColor.G, picProiLineColor.BackColor.B);
                    if (pLineRgb == null)
                    {
                        return;
                    }

                    ISimpleMarkerSymbol pSMarkerSym = new SimpleMarkerSymbolClass();
                    pSMarkerSym.Style        = esriSimpleMarkerStyle.esriSMSCircle;
                    pSMarkerSym.Size         = dblMinPtSize;
                    pSMarkerSym.OutlineSize  = dblLineWidth;
                    pSMarkerSym.Outline      = true;
                    pSMarkerSym.OutlineColor = (IColor)pLineRgb;
                    pSMarkerSym.Color        = (IColor)pSymbolRgb;

                    IGeoFeatureLayer            pGFLUncern    = (IGeoFeatureLayer)pflUncern;
                    IProportionalSymbolRenderer pUncernRender = new ProportionalSymbolRendererClass();
                    pUncernRender.LegendSymbolCount = 2; //Need to be changed 0219
                    pUncernRender.Field             = strUncerFieldName;
                    pUncernRender.MaxDataValue      = dblMaxValue;
                    pUncernRender.MinDataValue      = dblMinValue;
                    pUncernRender.MinSymbol         = (ISymbol)pSMarkerSym;
                    pUncernRender.ValueUnit         = esriUnits.esriUnknownUnits;
                    pUncernRender.BackgroundSymbol  = null;
                    pUncernRender.CreateLegendSymbols();

                    pGFLUncern.Renderer = (IFeatureRenderer)pUncernRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 3) // Bar
                {
                    string strUncerFieldName = cboUField.Text;
                    double dblMaxLength      = Convert.ToDouble(nudMaxBarHeight.Value);
                    double dblBarWidth       = Convert.ToDouble(nudBarWidth.Value);

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    int             intUncernIdx = pTable.FindField(strUncerFieldName);
                    IField          pUncernField = pTable.Fields.get_Field(intUncernIdx);
                    ICursor         pCursor      = pTable.Search(null, false);
                    IDataStatistics pDataStat    = new DataStatisticsClass();
                    pDataStat.Field  = pUncernField.Name;
                    pDataStat.Cursor = pCursor;
                    IStatisticsResults pStatResults = pDataStat.Statistics;
                    double             dblMaxValue  = pStatResults.Maximum;
                    pCursor.Flush();


                    IChartRenderer  chartRenderer  = new ChartRendererClass();
                    IRendererFields rendererFields = chartRenderer as IRendererFields;
                    rendererFields.AddField(strUncerFieldName);

                    IBarChartSymbol barChartSymbol = new BarChartSymbolClass();
                    barChartSymbol.Width = dblBarWidth;
                    IMarkerSymbol markerSymbol = barChartSymbol as IMarkerSymbol;
                    markerSymbol.Size = dblMaxLength;
                    IChartSymbol chartSymbol = barChartSymbol as IChartSymbol;
                    chartSymbol.MaxValue = dblMaxValue;
                    ISymbolArray symbolArray = barChartSymbol as ISymbolArray;
                    IFillSymbol  fillSymbol  = new SimpleFillSymbolClass();
                    fillSymbol.Color = pSnippet.getRGB(picBarSymCol.BackColor.R, picBarSymCol.BackColor.G, picBarSymCol.BackColor.B);
                    if (fillSymbol.Color == null)
                    {
                        return;
                    }
                    symbolArray.AddSymbol(fillSymbol as ISymbol);

                    if (chk3D.Checked)
                    {
                        I3DChartSymbol p3DChartSymbol = barChartSymbol as I3DChartSymbol;
                        p3DChartSymbol.Display3D = true;
                        p3DChartSymbol.Thickness = 3;
                    }
                    chartRenderer.ChartSymbol = barChartSymbol as IChartSymbol;
                    SimpleFillSymbol pBaseFillSym = new SimpleFillSymbolClass();
                    //pBaseFillSym.Color = pSnippet.getRGB(picBarSymCol.BackColor.R, picBarSymCol.BackColor.G, picBarSymCol.BackColor.B);
                    //chartRenderer.BaseSymbol = pBaseFillSym as ISymbol;
                    chartRenderer.UseOverposter = false;
                    chartRenderer.CreateLegend();
                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    pGFLUncern.Renderer = (IFeatureRenderer)chartRenderer;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                #region illumination
                //This function is not applied in this version. 032317 HK
                //}
                //    else if (tcUncern.SelectedIndex == 4) //illumination
                //    {
                //        frmProgress pfrmProgress = new frmProgress();
                //        pfrmProgress.lblStatus.Text = "Processing:";
                //        pfrmProgress.pgbProgress.Style = ProgressBarStyle.Marquee;
                //        pfrmProgress.Show();

                //        string strUncerFieldName = cboUField.Text;

                //        IGeoDataset geoDataset_output = createRasterfromPolygon(pFClass, strUncerFieldName, pFLayer, 100);

                //        double altitude = Convert.ToDouble(nudAltitude.Value);
                //        double azimuth = Convert.ToDouble(nudAzimuth.Value);
                //        object zFactor = Convert.ToDouble(nudZFactor.Value);


                //        ISurfaceOp2 pSurfOP = new RasterSurfaceOpClass();
                //        IRaster pOutputDS = (IRaster)pSurfOP.HillShade(geoDataset_output, azimuth, altitude, true, ref zFactor);

                //        ((IDataset)geoDataset_output).Delete();
                //        // Create a raster for viewing
                //        ESRI.ArcGIS.Carto.IRasterLayer rasterLayer = new ESRI.ArcGIS.Carto.RasterLayerClass();
                //        rasterLayer.CreateFromRaster(pOutputDS);

                //        //Calculate hillshade value at slope 0 to set as background value
                //        double dblRadian = (Math.PI / 180) * (90 - altitude);
                //        double dblBackValue = Math.Truncate(255 * Math.Cos(dblRadian));

                //        IRasterStretch pRasterStretch = new RasterStretchColorRampRendererClass();
                //        IColor pColor = new RgbColorClass();
                //        pColor.NullColor = true;
                //        pColor.Transparency = 0;
                //        pRasterStretch.Background = true;
                //        pRasterStretch.BackgroundColor = pColor;
                //        pRasterStretch.set_BackgroundValues(ref dblBackValue);

                //        rasterLayer.Name = "Uncertainty of " + strGCRenderField;
                //        rasterLayer.Renderer = pRasterStretch as IRasterRenderer;
                //        rasterLayer.Renderer.Update();

                //        //Apply Transparency
                //        ILayerEffects pLayerEffect = (ILayerEffects)rasterLayer;
                //        pLayerEffect.Transparency = Convert.ToInt16(nudTransparent.Value);

                //        pfrmProgress.Close();
                //        // Add the raster to the map
                //        pActiveView.FocusMap.AddLayer(rasterLayer);

                //    }

                //    mForm.axMapControl1.ActiveView.Refresh();
                //    mForm.axTOCControl1.Update();
                #endregion
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
예제 #8
0
        public void GraduatedColors(IFeatureLayer pfeatLyr, string sFieldName, int numclasses)
        {
            IGeoFeatureLayer pGeoFeatureL = pfeatLyr as IGeoFeatureLayer;
            object           dataFrequency;
            object           dataValues;
            bool             ok;
            int             breakIndex;
            ITable          pTable          = pGeoFeatureL.FeatureClass as ITable;//各个字段变成一个表
            ITableHistogram pTableHistogram = new BasicTableHistogramClass();
            IBasicHistogram pBasicHistogram = (IBasicHistogram)pTableHistogram;

            pTableHistogram.Field = sFieldName;
            pTableHistogram.Table = pTable;
            pBasicHistogram.GetHistogram(out dataValues, out dataFrequency);//获取渲染值及其出现的频率
            IClassifyGEN pClassify = new EqualIntervalClass();

            pClassify.Classify(dataValues, dataFrequency, ref numclasses);//进行等级划分
            double[]             Classes              = pClassify.ClassBreaks as double[];
            int                  classescount         = Classes.GetUpperBound(0);
            IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();

            pClassBreaksRenderer.Field                = sFieldName;   //分段字段
            pClassBreaksRenderer.BreakCount           = classescount; //设置分级数目
            pClassBreaksRenderer.SortClassesAscending = true;         //分机后的图例是否按升级顺序排列

            //分级颜色带的开始颜色和结束颜色(即分级颜色在此范围内)
            IHsvColor pFromColor = new HsvColorClass(); //起始颜色

            pFromColor.Hue        = 0;                  //黄色
            pFromColor.Saturation = 50;
            pFromColor.Value      = 96;
            IHsvColor ptocolor = new HsvColorClass(); //终止颜色

            ptocolor.Hue        = 80;                 //不知道什么颜色
            ptocolor.Saturation = 100;
            ptocolor.Value      = 96;


            //产生颜色带对象
            IAlgorithmicColorRamp pAlgorithmicColorRamp = new AlgorithmicColorRampClass();

            pAlgorithmicColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            pAlgorithmicColorRamp.FromColor = pFromColor;
            pAlgorithmicColorRamp.ToColor   = ptocolor;
            pAlgorithmicColorRamp.Size      = classescount;
            pAlgorithmicColorRamp.CreateRamp(out ok);

            //获得颜色
            IEnumColors pEnumColors = pAlgorithmicColorRamp.Colors;

            //symbol和break下标从0开始
            for (breakIndex = 0; breakIndex <= classescount - 1; breakIndex++)
            {
                IColor pColor = pEnumColors.Next();
                switch (pGeoFeatureL.FeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPolygon:
                {
                    ISimpleFillSymbol pSimpleFills = new SimpleFillSymbolClass();
                    pSimpleFills.Color = pColor;
                    pSimpleFills.Style = esriSimpleFillStyle.esriSFSSolid;
                    pClassBreaksRenderer.set_Symbol(breakIndex, (ISymbol)pSimpleFills);    //设置填充符号
                    pClassBreaksRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);   //设定每一分级的分级断点
                    break;
                }

                case esriGeometryType.esriGeometryPolyline:
                {
                    ISimpleLineSymbol pSimplelines = new SimpleLineSymbolClass();
                    pSimplelines.Color = pColor;

                    pClassBreaksRenderer.set_Symbol(breakIndex, (ISymbol)pSimplelines);    //设置填充符号
                    pClassBreaksRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);   //设定每一分级的分级断点
                    break;
                }

                case esriGeometryType.esriGeometryPoint:
                {
                    ISimpleMarkerSymbol pSimplemaker = new SimpleMarkerSymbolClass();
                    pSimplemaker.Color = pColor;

                    pClassBreaksRenderer.set_Symbol(breakIndex, (ISymbol)pSimplemaker);    //设置填充符号
                    pClassBreaksRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);   //设定每一分级的分级断点
                    break;
                }
                }
            }
            pGeoFeatureL.Renderer = (IFeatureRenderer)pClassBreaksRenderer;
            axMapControl1.Refresh();
            axTOCControl1.Update();
        }
예제 #9
0
        private void EvalRobustness(double[] cb)
        {
            int    intLIndex = m_pSnippet.GetIndexNumberFromLayerName(m_pActiveView, cboSourceLayer.Text);
            ILayer pLayer    = mForm.axMapControl1.get_Layer(intLIndex);

            m_pFLayer = pLayer as IFeatureLayer;
            IFeatureClass pFClass      = m_pFLayer.FeatureClass;
            string        strValueFld  = m_pRenderedLayer.strValueFldName;
            string        strUncernfld = string.Empty;

            if (m_pRenderedLayer.strUncernFldName == string.Empty)
            {
                strUncernfld = cboUncernFld.Text;
            }
            else
            {
                strUncernfld = m_pRenderedLayer.strUncernFldName;
            }
            if (strUncernfld == string.Empty)
            {
                return;
            }

            int intValueIdx   = pFClass.FindField(strValueFld);
            int intUncernIdx  = pFClass.FindField(strUncernfld);
            int intClassCount = cb.Length - 1;

            string strSavefldnm = txtFldName.Text;

            //strTempfldName = "MinSepfave";


            if (pFClass.FindField(strSavefldnm) == -1)
            {
                m_pSnippet.AddField(pFClass, strSavefldnm, esriFieldType.esriFieldTypeDouble);
            }

            int intSavefldIdx = pFClass.FindField(strSavefldnm);

            int   intFCounts = pFClass.FeatureCount(null);
            Chart pChart     = new Chart();

            IFeature pFeat = null;

            IFeatureCursor pFCursor = null;

            pFCursor = pFClass.Update(null, false);

            pFeat = pFCursor.NextFeature();
            Robustness[] pRobustness = new Robustness[intFCounts];
            double[]     arrValue    = new double[intFCounts];

            int i = 0;

            while (pFeat != null)
            {
                pRobustness[i] = new Robustness();
                pRobustness[i].Robustnesses = new double[intClassCount];

                double dblValue = Convert.ToDouble(pFeat.get_Value(intValueIdx));
                double dblStd   = Convert.ToDouble(pFeat.get_Value(intUncernIdx));

                double dblEntropy = 0;
                for (int j = 0; j < intClassCount; j++)
                {
                    double dblUpperZvalue  = (cb[j + 1] - dblValue) / dblStd;
                    double dblUpperConfLev = pChart.DataManipulator.Statistics.NormalDistribution(dblUpperZvalue);
                    double dblLowerZvalue  = (cb[j] - dblValue) / dblStd;
                    double dblLowerConfLev = pChart.DataManipulator.Statistics.NormalDistribution(dblLowerZvalue);
                    double dblProb         = dblUpperConfLev - dblLowerConfLev;
                    pRobustness[i].Robustnesses[j] = dblProb; //Probability of an observation to each class

                    if (dblProb != 0)
                    {
                        dblEntropy += dblProb * Math.Log(dblProb, 2);
                    }

                    if (j == 0)
                    {
                        if (dblValue >= cb[j] && dblValue <= cb[j + 1])
                        {
                            pRobustness[i].TargetClass = j;
                        }
                    }
                    else
                    {
                        if (dblValue > cb[j] && dblValue <= cb[j + 1])
                        {
                            pRobustness[i].TargetClass = j;
                        }
                    }
                }



                pRobustness[i].Entropy = ((double)(-1) * dblEntropy) / (Math.Log(intClassCount, 2));

                if (cboMeasure.Text == "Entropy")
                {
                    arrValue[i] = pRobustness[i].Entropy;
                    pFeat.set_Value(intSavefldIdx, pRobustness[i].Entropy);
                }
                else
                {
                    pFeat.set_Value(intSavefldIdx, pRobustness[i].Robustnesses[pRobustness[i].TargetClass]);
                    arrValue[i] = pRobustness[i].Robustnesses[pRobustness[i].TargetClass];
                }


                pFCursor.UpdateFeature(pFeat);
                pFeat = pFCursor.NextFeature();
                i++;
            }

            //Visualization
            //dblClsMean = new double[intClassCount, 3];
            //double dblSumRobustness = 0;
            //for (int j = 0; j < intFCounts; j++)
            //{
            //    dblSumRobustness = dblSumRobustness + arrRobustness[j, 0];
            //    for (int k = 0; k < intClassCount; k++)
            //    {
            //        if (arrRobustness[j, 1] == k)
            //        {
            //            dblClsMean[k, 0] = arrRobustness[j, 0] + dblClsMean[k, 0];
            //            dblClsMean[k, 1] = dblClsMean[k, 1] + 1;
            //        }
            //    }
            //}
            //for (int k = 0; k < intClassCount; k++)
            //{
            //    dblClsMean[k, 2] = dblClsMean[k, 0] / dblClsMean[k, 1];
            //}
            //dblMeanRobustness = dblSumRobustness / intFCounts;


            //switch (cboGCClassify.Text)
            //{
            //    case "Equal Interval":
            //        pClassifyGEN = new EqualIntervalClass();
            //        break;
            //    case "Geometrical Interval":
            //        pClassifyGEN = new GeometricalInterval();
            //        break;
            //    case "Natural Breaks":
            //        pClassifyGEN = new NaturalBreaksClass();
            //        break;
            //    case "Quantile":
            //        pClassifyGEN = new QuantileClass();
            //        break;
            //    case "StandardDeviation":
            //        pClassifyGEN = new StandardDeviationClass();
            //        break;
            //    default:
            //        pClassifyGEN = new NaturalBreaksClass();
            //        break;
            //}
            if (chkAddMap.Checked)
            {
                IClassifyGEN pClassifyGEN = new NaturalBreaksClass();

                IFeatureLayer pflUncern = new FeatureLayerClass();
                pflUncern.FeatureClass = pFClass;
                pflUncern.Name         = cboSourceLayer.Text + " " + cboMeasure.Text;
                pflUncern.Visible      = true;

                IGeoFeatureLayer pGeofeatureLayer = (IGeoFeatureLayer)pflUncern;

                ITableHistogram pTableHistogram2 = new BasicTableHistogramClass();
                ITable          pTable           = (ITable)pFClass;
                pTableHistogram2.Field = strSavefldnm;
                pTableHistogram2.Table = pTable;
                //IHistogram pHistogram = (IHistogram)pTableHistogram2;
                IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram2;

                object xVals, frqs;
                pHistogram.GetHistogram(out xVals, out frqs);
                pClassifyGEN.Classify(xVals, frqs, 4); //Fixed Class count
                double[] cb_uncern = (double[])pClassifyGEN.ClassBreaks;

                if (cboMeasure.Text == "Entropy")
                {
                    cb_uncern[1] = 0.4; cb_uncern[2] = 0.6; cb_uncern[3] = 0.75;
                }
                else
                {
                    cb_uncern[1] = 0.4; cb_uncern[2] = 0.6; cb_uncern[3] = 0.75;
                }


                ISpacingBreaksRenderer pSpacingBrksRenderers = new SpacingBreaksRendererClass();
                pSpacingBrksRenderers.arrClassBrks = cb_uncern;
                pSpacingBrksRenderers.arrValue     = arrValue;

                if (cboMeasure.Text == "Entropy")
                {
                    pSpacingBrksRenderers.dblFromSep = Convert.ToDouble(1);
                    pSpacingBrksRenderers.dblToSep   = Convert.ToDouble(20);
                }
                else
                {
                    pSpacingBrksRenderers.dblFromSep = Convert.ToDouble(20);
                    pSpacingBrksRenderers.dblToSep   = Convert.ToDouble(1);
                }

                pSpacingBrksRenderers.dblLineAngle = Convert.ToDouble(45);
                pSpacingBrksRenderers.dblLineWidth = Convert.ToDouble(0.1);
                pSpacingBrksRenderers.m_pLineRgb   = m_pSnippet.getRGB(0, 0, 0);
                if (pSpacingBrksRenderers.m_pLineRgb == null)
                {
                    return;
                }

                pSpacingBrksRenderers.strHeading        = cboMeasure.Text;
                pSpacingBrksRenderers.intRoundingDigits = 2;
                pSpacingBrksRenderers.CreateLegend();

                pGeofeatureLayer.Renderer = (IFeatureRenderer)pSpacingBrksRenderers;

                m_pActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                m_pActiveView.Refresh();
                mForm.axTOCControl1.Update();
            }
        }
예제 #10
0
        private void lblClassificationMethod_Click(object sender, EventArgs e)
        {
            if (layer2Symbolize == null)
            {
                return;
            }
            IFeatureClass featureClass = layer2Symbolize.FeatureClass;
            ITable        pTable       = (ITable)featureClass;

            ITableHistogram pTableHistogram2 = new BasicTableHistogramClass();
            IBasicHistogram pHistogram2      = (IBasicHistogram)pTableHistogram2;

            pTableHistogram2.Field = strRendererField;
            if (strNormalizeField.ToLower() != "none")
            {
                pTableHistogram2.NormField = strNormalizeField;
            }
            pTableHistogram2.Table = pTable;
            object dataFrequency;
            object dataValues;

            pHistogram2.GetHistogram(out dataValues, out dataFrequency);

            //下面是分级方法,用于根据获得的值计算得出符合要求的数据
            //根据条件计算出Classes和ClassesCount,numDesiredClasses为预定的分级数目
            IClassifyGEN pClassify = null;

            pClassify = new NaturalBreaksClass();
            int numDesiredClasses = gClassCount;

            pClassify.Classify(dataValues, dataFrequency, ref numDesiredClasses);

            UID pUid;

            pUid = new UIDClass();
            pUid = pClassify.ClassID;
            IClassificationDialog pClassDialog;

            pClassDialog = new ClassificationDialogClass();
            pClassDialog.Classification = pUid;
            pClassDialog.SetHistogramData(pHistogram2 as IHistogram);
            pClassDialog.ClassBreaks = pClassify.ClassBreaks;
            bool ok = pClassDialog.DoModal(0);

            if (ok == false)
            {
                return;
            }

            pUid         = pClassDialog.Classification;
            gClassbreaks = (double[])pClassDialog.ClassBreaks;
            switch (pUid.Value.ToString())
            {
            case "{62144BE1-E05E-11D1-AAAE-00C04FA334B3}":
                lblClassificationMethod.Text = "等间隔";
                break;

            case "{62144BE8-E05E-11D1-AAAE-00C04FA334B3}":
                lblClassificationMethod.Text = "已定义的间隔";
                break;

            case "{62144BE9-E05E-11D1-AAAE-00C04FA334B3}":
                lblClassificationMethod.Text = "分位数";
                break;

            case "{62144BEA-E05E-11D1-AAAE-00C04FA334B3}":
                lblClassificationMethod.Text = "自然裂点";
                break;

            case "{DC6D8015-49C2-11D2-AAFF-00C04FA334B3}":
                lblClassificationMethod.Text = "标准差";
                break;

            default:
                break;
            }
        }
예제 #11
0
        private void button5_Click(object sender, EventArgs e)
        {
            //先用TableHistogram统计,然后用某种实现IClassifyGEN的类来分类(classify),然后用ClassBreaksRenderer设置每个级别的渲染方式
            //SetBreak()的参数是该分类的下标,该分类的值上限
            ITable          table          = m_pTarFeatureLayer as ITable;
            ITableHistogram tableHistogram = new BasicTableHistogramClass();
            IBasicHistogram basicHistogram = tableHistogram as IBasicHistogram;
            int             curFieldIndex  = m_pTarFeatureLayer.FeatureClass.Fields.FindField(comboBox1.SelectedItem.ToString());
            IField          curField       = m_pTarFeatureLayer.FeatureClass.Fields.get_Field(curFieldIndex);

            tableHistogram.Table = table;
            tableHistogram.Field = curField.Name;
            basicHistogram.GetHistogram(out object v, out object f);
            IClassifyGEN clyGen = new EqualIntervalClass();

            clyGen.Classify(v, f, trackBar2.Value);
            double[]             classes    = clyGen.ClassBreaks as double[];
            int                  classCount = classes.GetUpperBound(0);
            IClassBreaksRenderer cbr        = new ClassBreaksRendererClass
            {
                Field      = curField.Name,
                BreakCount = classCount
            };
            IAlgorithmicColorRamp acr = new AlgorithmicColorRampClass
            {
                FromColor = m_pFillColor,
                ToColor   = m_pOutlineColor,
                Size      = classCount
            };

            acr.CreateRamp(out _);
            IEnumColors enumC    = acr.Colors;
            IColor      curColor = enumC.Next();

            for (int i = 0; i < classCount; i++)
            {
                switch (m_pTarFeatureLayer.FeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPolygon:
                {
                    ISimpleFillSymbol sfs = new SimpleFillSymbolClass
                    {
                        Color = curColor
                    };
                    cbr.set_Symbol(i, sfs as ISymbol);
                    cbr.set_Break(i, classes[i + 1]);
                    break;
                }

                case esriGeometryType.esriGeometryPolyline:
                {
                    ISimpleLineSymbol sls = new SimpleLineSymbolClass();
                    sls.Color = curColor;
                    sls.Style = esriSimpleLineStyle.esriSLSSolid;
                    cbr.set_Symbol(i, sls as ISymbol);
                    cbr.set_Break(i, classes[i + 1]);
                    break;
                }
                }
                curColor = enumC.Next();
            }
            m_pTarGeoFeatureLayer.Renderer = cbr as IFeatureRenderer;
            frmMainOper(OperationType.RefreshMapCtrl);
            frmMainOper(OperationType.UpdateTOCCtrl);
        }
예제 #12
0
        private void DrawCCMaps()
        {
            m_intClassNumber = Convert.ToInt32(nudGCNClasses.Value);
            IFeatureClass pFClass = pFLayer.FeatureClass;

            //Determine Class Breaks for variable
            int intValueFldIdx = pFClass.FindField(strVarFldName);

            ITable       pTable       = (ITable)pFClass;
            IClassifyGEN pClassifyGEN = null;

            switch (cboGCClassify.Text)
            {
            case "Equal Interval":
                pClassifyGEN = new EqualIntervalClass();
                break;

            case "Geometrical Interval":
                pClassifyGEN = new GeometricalInterval();
                break;

            case "Natural Breaks":
                pClassifyGEN = new NaturalBreaksClass();
                break;

            case "Quantile":
                pClassifyGEN = new QuantileClass();
                break;

            case "StandardDeviation":
                pClassifyGEN = new StandardDeviationClass();
                break;

            default:
                pClassifyGEN = new NaturalBreaksClass();
                break;
            }


            ITableHistogram pTableHistogram = new BasicTableHistogramClass();

            pTableHistogram.Field = strVarFldName;
            pTableHistogram.Table = pTable;
            //IHistogram pHistogram = (IHistogram)pTableHistogram2;
            IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram;

            ////Not working in ArcGIS 10.5 022417 HK
            //ITableHistogram pTableHistogram = new TableHistogramClass();
            //pTableHistogram.Field = strVarFldName;
            //pTableHistogram.Table = pTable;
            //IHistogram pHistogram = (IHistogram)pTableHistogram;

            object xVals, frqs;

            pHistogram.GetHistogram(out xVals, out frqs);
            pClassifyGEN.Classify(xVals, frqs, m_intClassNumber);
            double[] cb = (double[])pClassifyGEN.ClassBreaks;

            //Class Determinations for vertical and horizontal axis

            if (m_VerticalBreaks == null)
            {
                pClassifyGEN          = new QuantileClass(); //Using Quatile
                pTableHistogram       = new BasicTableHistogramClass();
                pTableHistogram.Field = strVerConFldName;
                pTableHistogram.Table = pTable;
                pHistogram            = (IBasicHistogram)pTableHistogram;

                pHistogram.GetHistogram(out xVals, out frqs);
                pClassifyGEN.Classify(xVals, frqs, intVerCnt);
                m_VerticalBreaks = (double[])pClassifyGEN.ClassBreaks;
            }

            if (m_HorizontalBreaks == null)
            {
                pClassifyGEN          = new QuantileClass(); //Using Quatile
                pTableHistogram       = new BasicTableHistogramClass();
                pTableHistogram.Field = strHorConFldName;
                pTableHistogram.Table = pTable;
                pHistogram            = (IBasicHistogram)pTableHistogram;

                pHistogram.GetHistogram(out xVals, out frqs);
                pClassifyGEN.Classify(xVals, frqs, intHorCnt);
                m_HorizontalBreaks = (double[])pClassifyGEN.ClassBreaks;
            }

            //Create Renderer
            IClassBreaksRenderer pRender = new ClassBreaksRenderer();

            pRender.Field        = strVarFldName;
            pRender.BreakCount   = m_intClassNumber;
            pRender.MinimumBreak = cb[0];

            string strColorRamp = cboColorRamp.Text;

            IEnumColors pEnumColors = MultiPartColorRamp(strColorRamp, "CIE Lab", m_intClassNumber);

            pEnumColors.Reset();

            int[,] arrColors = new int[m_intClassNumber, 3];

            for (int k = 0; k < m_intClassNumber; k++)
            {
                IColor    pColor    = pEnumColors.Next();
                IRgbColor pRGBColor = new RgbColorClass();
                pRGBColor.RGB = pColor.RGB;

                arrColors[k, 0] = pRGBColor.Red;
                arrColors[k, 1] = pRGBColor.Green;
                arrColors[k, 2] = pRGBColor.Blue;
            }

            pEnumColors.Reset();
            IRgbColor pColorOutline = new RgbColor();

            //Can Change the color in here!
            pColorOutline = m_pSnippet.getRGB(picOutlineColor.BackColor.R, picOutlineColor.BackColor.G, picOutlineColor.BackColor.B);

            double dblGCOutlineSize = Convert.ToDouble(nudOutlinewidth.Value);

            ICartographicLineSymbol pOutLines = new CartographicLineSymbol();

            pOutLines.Width = dblGCOutlineSize;
            pOutLines.Color = (IColor)pColorOutline;

            //' use this interface to set dialog properties
            IClassBreaksUIProperties pUIProperties = (IClassBreaksUIProperties)pRender;

            pUIProperties.ColorRamp = "Custom";
            ISimpleFillSymbol pSimpleFillSym;

            pEnumColors.Reset();

            double dblAdding = Math.Pow(0.1, m_intRounding);

            for (int j = 0; j < m_intClassNumber; j++)
            {
                pRender.Break[j] = cb[j + 1];

                if (j == 0)
                {
                    pRender.Label[j] = Math.Round(cb[j], m_intRounding).ToString("N" + m_intRounding.ToString()) + " - " + Math.Round(cb[j + 1], 2).ToString("N" + m_intRounding.ToString());
                }
                else
                {
                    pRender.Label[j] = Math.Round(cb[j] + dblAdding, m_intRounding).ToString("N" + m_intRounding.ToString()) + " - " + Math.Round(cb[j + 1], 2).ToString("N" + m_intRounding.ToString());
                }

                pUIProperties.LowBreak[j] = cb[j];

                pSimpleFillSym = new SimpleFillSymbolClass();
                IRgbColor pRGBColor = m_pSnippet.getRGB(arrColors[j, 0], arrColors[j, 1], arrColors[j, 2]);
                pSimpleFillSym.Color   = (IColor)pRGBColor;
                pSimpleFillSym.Outline = pOutLines;
                pRender.Symbol[j]      = (ISymbol)pSimpleFillSym;
            }

            //Background Layer
            ISimpleRenderer   pSimpleRender = new SimpleRendererClass();
            ISimpleFillSymbol pBGSymbol     = new SimpleFillSymbolClass();

            pBGSymbol.Color = (IColor)m_pSnippet.getRGB(picBGColor.BackColor.R, picBGColor.BackColor.G, picBGColor.BackColor.B);

            ICartographicLineSymbol pBGOutLines = new CartographicLineSymbol();

            pBGOutLines.Width = 0;
            pBGOutLines.Color = m_pSnippet.getRGB(255, 255, 255);
            pBGSymbol.Outline = pBGOutLines;

            pSimpleRender.Symbol = (ISymbol)pBGSymbol;

            IFeatureLayer pflBG = new FeatureLayerClass();

            pflBG.FeatureClass = pFClass;

            IGeoFeatureLayer pGeoBG = (IGeoFeatureLayer)pflBG;

            pGeoBG.Renderer   = (IFeatureRenderer)pSimpleRender;
            pGeoBG.Selectable = false;

            //Feature Count for each map
            m_intsFeatureCnts = new int[intVerCnt * intHorCnt];

            int l = 0;

            for (int i = 0; i < intVerCnt; i++)
            {
                for (int j = 0; j < intHorCnt; j++)
                {
                    IFeatureLayer pflOutput = new FeatureLayerClass();
                    pflOutput.FeatureClass = pFClass;

                    IGeoFeatureLayer pGeofeatureLayer = (IGeoFeatureLayer)pflOutput;

                    pGeofeatureLayer.Renderer = (IFeatureRenderer)pRender;

                    IFeatureLayerDefinition2 pFDefinition = (IFeatureLayerDefinition2)pGeofeatureLayer;
                    string strWhereClause = null;

                    if (i == 0 && j == 0)
                    {
                        strWhereClause = strVerConFldName + " >= " + m_VerticalBreaks[i].ToString() + " AND " +
                                         strVerConFldName + " <= " + m_VerticalBreaks[i + 1].ToString() + " AND " +
                                         strHorConFldName + " >= " + m_HorizontalBreaks[j].ToString() + " AND " +
                                         strHorConFldName + " <= " + m_HorizontalBreaks[j + 1].ToString();
                    }
                    else if (i != 0 && j == 0)
                    {
                        strWhereClause = strVerConFldName + " > " + m_VerticalBreaks[i].ToString() + " AND " +
                                         strVerConFldName + " <= " + m_VerticalBreaks[i + 1].ToString() + " AND " +
                                         strHorConFldName + " >= " + m_HorizontalBreaks[j].ToString() + " AND " +
                                         strHorConFldName + " <= " + m_HorizontalBreaks[j + 1].ToString();
                    }
                    else if (i == 0 && j != 0)
                    {
                        strWhereClause = strVerConFldName + " >= " + m_VerticalBreaks[i].ToString() + " AND " +
                                         strVerConFldName + " <= " + m_VerticalBreaks[i + 1].ToString() + " AND " +
                                         strHorConFldName + " > " + m_HorizontalBreaks[j].ToString() + " AND " +
                                         strHorConFldName + " <= " + m_HorizontalBreaks[j + 1].ToString();
                    }
                    else
                    {
                        strWhereClause = strVerConFldName + " > " + m_VerticalBreaks[i].ToString() + " AND " +
                                         strVerConFldName + " <= " + m_VerticalBreaks[i + 1].ToString() + " AND " +
                                         strHorConFldName + " > " + m_HorizontalBreaks[j].ToString() + " AND " +
                                         strHorConFldName + " <= " + m_HorizontalBreaks[j + 1].ToString();
                    }

                    pFDefinition.DefinitionExpression = strWhereClause;

                    IQueryFilter pQfilter = new QueryFilterClass();
                    pQfilter.WhereClause = strWhereClause;

                    m_intsFeatureCnts[l] = pGeofeatureLayer.FeatureClass.FeatureCount(pQfilter);
                    m_axMapControls[l].ActiveView.FocusMap.ClearLayers();
                    m_axMapControls[l].ActiveView.FocusMap.AddLayer(pGeoBG);
                    m_axMapControls[l].ActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                    m_axMapControls[l].ActiveView.Extent = m_axMapControls[l].ActiveView.FullExtent;
                    m_axMapControls[l].ActiveView.Refresh();
                    l++;
                }
            }

            lblVariable.Text = "Selected Variable: " + strVarFldName;
            UpdateRange(lvSymbol, m_intClassNumber, cb, arrColors, m_intRounding);

            if (m_blnAddBoxes)
            {
                UpdateTextBoxes();
            }
            else
            {
                AddTextBoxes();
            }

            UpdateLabels();
            UpdateHorVerLabels();
        }
예제 #13
0
        void ClassifyColor()
        {
            IGeoFeatureLayer geoFeatureLayer = mapControl.Map.get_Layer(17) as IGeoFeatureLayer;
            string           a = geoFeatureLayer.Name;
            object           dataFrequency, dataValues;


            ITableHistogram tableHistogram = new BasicTableHistogramClass();
            IBasicHistogram basicHistogram = (IBasicHistogram)tableHistogram;

            tableHistogram.Field = cmbSelField.Text;
            tableHistogram.Table = geoFeatureLayer.FeatureClass as ITable;



            basicHistogram.GetHistogram(out dataValues, out dataFrequency);
            IClassifyGEN classifyGEN = new EqualIntervalClass();

            classifyGEN.Classify(dataValues, dataFrequency, Convert.ToInt32(cmbnumclasses.Text));


            double[]             classes             = classifyGEN.ClassBreaks as double[];
            int                  classesCount        = classes.GetUpperBound(0);
            IClassBreaksRenderer classBreaksRenderer = new ClassBreaksRendererClass();



            classBreaksRenderer.Field                = cmbSelField.Text;
            classBreaksRenderer.BreakCount           = classesCount;
            classBreaksRenderer.SortClassesAscending = true;



            IHsvColor fromColor = new HsvColorClass();

            fromColor.Hue   = 0; fromColor.Saturation = 50;
            fromColor.Value = 96;
            IHsvColor toColor = new HsvColorClass();

            toColor.Hue        = 80;
            toColor.Saturation = 100;
            toColor.Value      = 96;
            bool ok;



            //产生色带
            IAlgorithmicColorRamp algorithmicCR = new AlgorithmicColorRampClass();

            algorithmicCR.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            algorithmicCR.FromColor = fromColor;
            algorithmicCR.ToColor   = toColor;
            algorithmicCR.Size      = classesCount;
            algorithmicCR.CreateRamp(out ok);



            //获得颜色
            IEnumColors enumColors = algorithmicCR.Colors;

            for (int breakIndex = 0; breakIndex <= classesCount - 1; breakIndex++)
            {
                IColor            color      = enumColors.Next();
                ISimpleFillSymbol simpleFill = new SimpleFillSymbolClass();
                simpleFill.Color = color;
                simpleFill.Style = esriSimpleFillStyle.esriSFSSolid;
                classBreaksRenderer.set_Symbol(breakIndex, (ISymbol)simpleFill);
                classBreaksRenderer.set_Break(breakIndex, classes[breakIndex + 1]);
            }

            geoFeatureLayer.Renderer = (IFeatureRenderer)classBreaksRenderer;
            mapControl.Refresh();
            mapControl.ActiveView.Refresh();


            tocControl.Update();
        }
예제 #14
0
        // 分级色彩符号化
        public static void GraduatedColors(IFeatureLayer featureLayer, string fieldName, int numClasses, IMapControl2 mapControl, AxTOCControl tocControl)
        {
            object          dataFrequency;
            object          dataValue;
            int             breakIndex;
            ITable          pTable          = featureLayer.FeatureClass as ITable;
            ITableHistogram pTableHistogram = new BasicTableHistogramClass()
            {
                Field = fieldName, Table = pTable
            };
            IBasicHistogram pBasicHistogram = (IBasicHistogram)pTableHistogram;

            // 获取渲染字段的值及其出现的频率
            pBasicHistogram.GetHistogram(out dataValue, out dataFrequency);
            IClassifyGEN pClassifyGEN = new EqualIntervalClass();

            try { pClassifyGEN.Classify(dataValue, dataFrequency, ref numClasses); }
            catch { }
            // 返回一个数组
            double[]             Classes      = pClassifyGEN.ClassBreaks as double[];
            int                  ClassesCount = Classes.GetUpperBound(0);
            IClassBreaksRenderer pRenderer    = new ClassBreaksRendererClass()
            {
                // 分级字段 分级数目 分级后的图例是否按升级顺序排序
                Field = fieldName, BreakCount = ClassesCount, SortClassesAscending = true
            };
            // 设置分级说色所需颜色带的起止颜色
            //IHsvColor pFromColor = GetHsvColor(0, 50, 96);
            //IHsvColor pToColor = GetHsvColor(80, 100, 96);
            IRgbColor pFromColor = GetRgbColor(255, 200, 200);
            IRgbColor pToColor   = GetRgbColor(255, 0, 0);
            // 生成颜色带对象
            IAlgorithmicColorRamp pColorRamp = CreateColorRamp(pFromColor, pToColor, ClassesCount);
            // 获取色带颜色集
            IEnumColors pEnumColors = pColorRamp.Colors;

            // 逐一设置填充符号及每一分级的分级断点
            for (breakIndex = 0; breakIndex < ClassesCount; breakIndex++)
            {
                IColor  pColor  = pEnumColors.Next();
                ISymbol pSymbol = null;
                switch (featureLayer.FeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPolygon:
                    pSymbol = new SimpleFillSymbolClass()
                    {
                        Color = pColor, Style = esriSimpleFillStyle.esriSFSSolid
                    };
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    pSymbol = new SimpleLineSymbolClass()
                    {
                        Color = pColor
                    };
                    break;

                case esriGeometryType.esriGeometryPoint:
                    pSymbol = new SimpleMarkerSymbolClass()
                    {
                        Color = pColor
                    };
                    break;
                }
                // 设置填充符号
                pRenderer.set_Symbol(breakIndex, pSymbol);
                // 设置每一级的分级断点
                pRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);
            }
            (featureLayer as IGeoFeatureLayer).Renderer = pRenderer as IFeatureRenderer;
            mapControl.Refresh();
            tocControl.Update();
        }
        /// <summary>
        /// 分级符号渲染矢量数据
        /// </summary>
        /// <param name="pFeatureLayer"></param>
        /// <param name="mField"></param>
        public void SimpleRenderByColor(IFeatureLayer pFeatureLayer, string mField)
        {
            //分5类
            int breakCount = 5;

            try
            {
                var pGeoFeatureLayer = (IGeoFeatureLayer)pFeatureLayer;
                //计算最大最小值
                var pTable = (ITable)pGeoFeatureLayer;
                if (pTable.FindField(mField) == -1)
                {
                    MessageBox.Show("此类型水质数据不存在");
                    return;
                }

                IQueryFilter pQueryFilter = new QueryFilterClass();
                pQueryFilter.AddField("");
                var pCursor = pTable.Search(pQueryFilter, true);
                //获取统计结果
                IDataStatistics pDataStatistics = new DataStatisticsClass();
                pDataStatistics.Cursor = pCursor;
                //设置要统计字段的名称
                pDataStatistics.Field = mField;
                //获取统计的结果
                //背景色
                IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
                pFillSymbol.Color = GetColor(0, 0, 0);
                //点符号样式
                ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();
                pSimpleMarkerSymbol.Outline      = true;
                pSimpleMarkerSymbol.OutlineColor = GetColor(0, 0, 0);

                //分级符号
                //获取统计数据及频率
                ITableHistogram pTableHistogram = new BasicTableHistogramClass();
                pTableHistogram.Field = mField;
                pTableHistogram.Table = pTable;
                object          dataValue, dataFrequency;
                IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram;
                pHistogram.GetHistogram(out dataValue, out dataFrequency);
                IClassifyGEN pClassifyGen = new NaturalBreaksClass();
                //产生种类
                pClassifyGen.Classify(dataValue, dataFrequency, ref breakCount);
                object   ob           = pClassifyGen.ClassBreaks;
                double[] classes      = (double[])ob;
                int      classesCount = classes.Length;
                //定义分类渲染
                IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();
                pClassBreaksRenderer.Field                = mField;
                pClassBreaksRenderer.BreakCount           = classesCount;
                pClassBreaksRenderer.SortClassesAscending = true;
                pClassBreaksRenderer.MinimumBreak         = classes[0];
                //设置要素颜色
                IColor pColor = GetColor(0, 217, 0);
                for (int i = 0; i < classesCount; i++)
                {
                    ISimpleFillSymbol pFillSymbol1 = new SimpleFillSymbolClass();
                    pSimpleMarkerSymbol.Color = pColor;
                    pFillSymbol1.Style        = esriSimpleFillStyle.esriSFSSolid;

                    pSimpleMarkerSymbol.Size = 2 * (i + 1);
                    pClassBreaksRenderer.BackgroundSymbol = pFillSymbol1;
                    pClassBreaksRenderer.set_Symbol(i, (ISymbol)pSimpleMarkerSymbol);
                    pClassBreaksRenderer.set_Break(i, classes[i]);
                }
                pGeoFeatureLayer.Renderer = (IFeatureRenderer)pClassBreaksRenderer;

                this._pMap.AddLayer(pGeoFeatureLayer);
                IActiveView pActiveView = _pMap as IActiveView;
                if (pActiveView != null)
                {
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    pActiveView.Extent = pActiveView.FullExtent;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("渲染出错!\n" + e.ToString());
            }
        }