Пример #1
0
 private void chooseNumericField()                                       //选择数值型字段
 {
     fieldChoose(field =>
     {
         if (field.Type == esriFieldType.esriFieldTypeDouble || field.Type == esriFieldType.esriFieldTypeSingle || field.Type == esriFieldType.esriFieldTypeInteger ||
             field.Type == esriFieldType.esriFieldTypeOID || field.Type == esriFieldType.esriFieldTypeSmallInteger)
         {
             IBasicHistogram pBasicHis = new BasicTableHistogramClass();
             ITableHistogram pTabHis   = (ITableHistogram)pBasicHis;
             pTabHis.Field             = field.Name;
             ILayer Layer  = (ILayer)featureLayer;
             ITable pTab   = (ITable)Layer;
             pTabHis.Table = pTab;
             object doubleArrVal, longArrFreq;
             pBasicHis.GetHistogram(out doubleArrVal, out longArrFreq);
             double[] ArrVal = (double[])doubleArrVal;
             if (ArrVal.Length == 1)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(false);
         }
     });
 }
Пример #2
0
        private void drawLine()                                                 //在表中画出值的频率分布线
        {
            IBasicHistogram pBasicHis = new BasicTableHistogramClass();
            ITableHistogram pTabHis   = (ITableHistogram)pBasicHis;

            pTabHis.Field = comboBoxEdit1.Text;
            ILayer Layer = (ILayer)featureLayer;
            ITable pTab  = (ITable)Layer;

            pTabHis.Table = pTab;
            object doubleArrVal, longArrFreq;

            pBasicHis.GetHistogram(out doubleArrVal, out longArrFreq);

            double[]       ArrVal  = (double[])doubleArrVal;
            System.Int32[] ArrFreq = (System.Int32[])longArrFreq;
            if (ArrVal.Length < 50)
            {
                valueChooseInChart1.drawLine(ArrVal, ArrFreq, Convert.ToInt16(spinEdit1.Text));
            }
            else
            {
                valueChooseInChart1.drawline(ArrVal.Min(), ArrVal.Max(), Convert.ToInt16(spinEdit1.Text));
            }
        }
Пример #3
0
 public Thematic(IMapControl3 mapControl)
 {
     if (mapControl != null)
     {
         this._mapControl = mapControl;
     }
     _renderer = new ClassBreaksRendererClass();
     _classify = new QuantileClass();
     _tableHistogram = new BasicTableHistogramClass();
     _colorFrom = new HsvColorClass();
     _colorTo = new HsvColorClass();
     _algClrRamp = new AlgorithmicColorRampClass();
 }
Пример #4
0
        public static void classifyRender(IFeatureLayer featLayer, string classMethod, string fieldName, IColorRamp colorRamp, int count)
        {
            try
            {
                //值分级
                IBasicHistogram pBasicHis = new BasicTableHistogramClass();
                ITableHistogram pTabHis   = (ITableHistogram)pBasicHis;
                IClassifyGEN    pClassify = null;
                switch (classMethod)
                {
                case "等间距分级":
                    pClassify = new EqualIntervalClass();
                    break;

                case "自然断点分级":
                    pClassify = new NaturalBreaksClass();
                    break;
                }
                pTabHis.Field = fieldName;
                ILayer Layer = (ILayer)featLayer;
                ITable pTab  = (ITable)Layer;
                pTabHis.Table = pTab;
                object doubleArrVal, longArrFreq;
                pBasicHis.GetHistogram(out doubleArrVal, out longArrFreq);

                int nDes = count;
                pClassify.Classify(doubleArrVal, longArrFreq, ref nDes);
                double[] ClassNum;
                ClassNum = (double[])pClassify.ClassBreaks;
                int ClassCountResult         = ClassNum.GetUpperBound(0);
                IClassBreaksRenderer pRender = new ClassBreaksRendererClass();
                pRender.BreakCount = ClassCountResult;
                pRender.Field      = fieldName;
                ISimpleFillSymbol pSym;
                IColor            pColor;
                for (int j = 0; j < ClassCountResult; j++)
                {
                    pColor = colorRamp.get_Color(j * (colorRamp.Size - 1) / (ClassCountResult - 1));
                    pRender.set_Symbol(j, getISymbolByGeomType(featLayer, pColor));
                    pRender.set_Break(j, ClassNum[j + 1]);
                    pRender.set_Label(j, ClassNum[j].ToString("0.00") + " - " + ClassNum[j + 1].ToString("0.00"));
                }

                IGeoFeatureLayer pGeoLyr = (IGeoFeatureLayer)Layer;
                pGeoLyr.Renderer = (IFeatureRenderer)pRender;
            }
            catch {
                XtraMessageBox.Show("嗯,哪个,就一个值,别分级了好不好^_^");
            }
        }
Пример #5
0
 private int method_7(string string_3, ITable itable_0)
 {
     try
     {
         ITableHistogram tableHistogram = new BasicTableHistogram() as ITableHistogram;
         tableHistogram.Table = itable_0;
         tableHistogram.Field = string_3;
         ITableHistogram histogram = tableHistogram as ITableHistogram;
         if ((histogram as IStatisticsResults).Count == 0)
         {
             return(0);
         }
         return((int)(histogram as IStatisticsResults).Maximum);
     }
     catch (Exception exception)
     {
         Logger.Current.Error("", exception, "");
     }
     return(1);
 }
Пример #6
0
        public void LayerRender()
        {
            try
            {
                //值分级
                IBasicHistogram pBasicHis = new BasicTableHistogramClass();
                ITableHistogram pTabHis   = (ITableHistogram)pBasicHis;
                IClassifyGEN    pClassify = null;
                switch (classname)
                {
                case "自然断点分级":
                    pClassify = new NaturalBreaksClass();
                    break;

                case "等间距分级":
                    pClassify = new EqualIntervalClass();
                    break;
                }
                pTabHis.Field = FiledName;
                //IGeoFeatureLayer geolayer = (IGeoFeatureLayer)Layer;
                ITable pTab = (ITable)Layer;
                pTabHis.Table = pTab;
                object doubleArrVal, longArrFreq;
                pBasicHis.GetHistogram(out doubleArrVal, out longArrFreq);

                int nDes = count;
                pClassify.Classify(doubleArrVal, longArrFreq, ref nDes);
                object   classes = pClassify.ClassBreaks;
                double[] ClassNum;
                ClassNum = (double[])pClassify.ClassBreaks;
                int ClassCountResult         = ClassNum.GetUpperBound(0);
                IClassBreaksRenderer pRender = new ClassBreaksRendererClass();
                pRender.BreakCount = ClassCountResult;
                pRender.Field      = FiledName;
                ISimpleFillSymbol pSym;
                IColor            pColor;
                for (int j = 0; j < ClassCountResult; j++)
                {
                    pColor     = ramp.get_Color(j * (ramp.Size / ClassCountResult));
                    pSym       = new SimpleFillSymbolClass();
                    pSym.Color = pColor;
                    pRender.set_Symbol(j, (ISymbol)pSym);
                    pRender.set_Break(j, ClassNum[j + 1]);
                    if (ClassNum[j].ToString().Contains("."))
                    {
                        pRender.set_Label(j, ClassNum[j].ToString("0.000") + " - " + ClassNum[j + 1].ToString("0.000"));
                    }
                    else
                    {
                        pRender.set_Label(j, ClassNum[j].ToString() + " - " + ClassNum[j + 1].ToString());
                    }
                }

                IGeoFeatureLayer pGeoLyr = (IGeoFeatureLayer)Layer;
                pGeoLyr.Renderer = (IFeatureRenderer)pRender;
                axmapcontrol.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                axtoccontrol.Update();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #7
0
 public static void UsingRasterClassifyRendered(IRasterLayer irasterLayer_0, int int_0, string string_0)
 {
     try
     {
         bool        flag;
         IRaster     raster = irasterLayer_0.Raster;
         IRasterBand band   = (raster as IRasterBandCollection).Item(0);
         band.HasTable(out flag);
         if (flag)
         {
             int  num2;
             bool flag2;
             IRasterClassifyColorRampRenderer renderer = new RasterClassifyColorRampRenderer();
             IRasterRenderer renderer2 = renderer as IRasterRenderer;
             renderer2.Raster = raster;
             ITable          attributeTable = band.AttributeTable;
             ITableHistogram tableHistogram = new BasicTableHistogram() as ITableHistogram;
             tableHistogram.Field = string_0;
             tableHistogram.Table = attributeTable;
             ITableHistogram histogram = tableHistogram as ITableHistogram;
             double          maximum   = (histogram as IStatisticsResults).Maximum;
             IClassify       classify  = new EqualInterval() as IClassify;
             (classify as IClassifyMinMax).Minimum = (histogram as IStatisticsResults).Minimum;
             (classify as IClassifyMinMax).Maximum = (histogram as IStatisticsResults).Maximum;
             int_0--;
             classify.Classify(ref int_0);
             object classBreaks = classify.ClassBreaks;
             UID    classID     = classify.ClassID;
             IRasterClassifyUIProperties properties = renderer as IRasterClassifyUIProperties;
             properties.ClassificationMethod = classID;
             renderer.ClassCount             = int_0;
             renderer.ClassField             = string_0;
             for (num2 = 0; num2 < int_0; num2++)
             {
                 renderer.set_Break(num2, ((double[])classBreaks)[num2]);
             }
             IColorRamp ramp = ColorManage.CreateColorRamp();
             ramp.Size = int_0;
             ramp.CreateRamp(out flag2);
             IFillSymbol symbol = new SimpleFillSymbol();
             for (num2 = 0; num2 < renderer.ClassCount; num2++)
             {
                 double num4;
                 symbol.Color = ramp.get_Color(num2);
                 renderer.set_Symbol(num2, symbol as ISymbol);
                 double num3 = ((double[])classBreaks)[num2];
                 if (num2 == (renderer.ClassCount - 1))
                 {
                     num4 = maximum;
                 }
                 else
                 {
                     num4 = ((double[])classBreaks)[num2 + 1];
                 }
                 renderer.set_Label(num2, num3.ToString() + "-" + num4.ToString());
             }
             renderer2.Update();
             irasterLayer_0.Renderer = renderer as IRasterRenderer;
         }
         else
         {
             UsingRasterClassifyRendered1(irasterLayer_0, int_0, string_0);
         }
     }
     catch (Exception exception)
     {
         CErrorLog.writeErrorLog(null, exception, "栅格渲染");
     }
 }
Пример #8
0
        public void ApplyClsssBreaks(IGeoFeatureLayer geoLayer, string aFieldName, long numBreaks)
        {
            //Create a Table from the geofeature layer
            ITable table = geoLayer as ITable;
            //ITableHistogram tableHistogram=new TableHistogram(); that is error but canbe coded by following
            TableHistogram  tableHistogram2 = new TableHistogram();
            ITableHistogram tableHistogram  = tableHistogram2 as ITableHistogram;

            tableHistogram.Table = table;
            tableHistogram.Field = aFieldName;
            IHistogram histogram = tableHistogram as IHistogram;
            object     vValues;
            object     vFregs;

            //先统计每个值和各个值出现的次数
            histogram.GetHistogram(out vValues, out vFregs);

            //Classify the data
            IClassifyGEN classifyGEN = new EqualInterval();
            int          intBreaks   = Convert.ToInt32(numBreaks);

            classifyGEN.Classify(vValues, vFregs, ref intBreaks);

            double[] vBreaks = (double[])classifyGEN.ClassBreaks;
            //books
            int classCount = vBreaks.GetUpperBound(0);
            //Create the ClassBreaksRenderer
            IClassBreaksRenderer classBreaksRenderer = new ClassBreaksRenderer();

            //assigh a field as breaked
            classBreaksRenderer.Field = aFieldName;
            //passed as a string to the sub routine
            //classBreaksRenderer.BreakCount =classCount;
            classBreaksRenderer.BreakCount           = (int)(numBreaks);
            classBreaksRenderer.SortClassesAscending = false;


            IRgbColor fromColor = new RgbColor();

            fromColor.UseWindowsDithering = true;
            fromColor.RGB = Information.RGB(0, 0, 255);
            IRgbColor toColor = new RgbColor();

            toColor.UseWindowsDithering = true;
            toColor.RGB = Information.RGB(255, 0, 0);
            //Set up the fill symbol
            ISymbol pSym;
            //ISimpleFillSymbol sym = new SimpleFillSymbol();
            IColor fillColor;

            MessageBox.Show("vBreaks.Length: " + vBreaks.Length.ToString());

            IEnumColors colors = GetColors(fromColor.RGB, toColor.RGB, numBreaks);

            for (int i = 0; i <= (vBreaks.Length - 2); i++)
            {
                fillColor = colors.Next();
                //code by jin
                if (geoLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                {
                    ISimpleFillSymbol sym = new SimpleFillSymbol();
                    sym.Color = fillColor;
                    pSym      = sym as ISymbol;
                }
                else if (geoLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                {
                    ISimpleLineSymbol sym = new SimpleLineSymbol();
                    sym.Color = fillColor;
                    pSym      = sym as ISymbol;
                }
                else
                {
                    ISimpleMarkerSymbol sym = new SimpleMarkerSymbol();
                    sym.Color = fillColor;
                    pSym      = sym as ISymbol;
                }
                classBreaksRenderer.set_Break(i, vBreaks[i + 1]);
                classBreaksRenderer.set_Symbol(i, pSym);
                geoLayer.Renderer = classBreaksRenderer as IFeatureRenderer;
                axMapControl1.ActiveView.Refresh();
                axTOCControl1.Update();
            }
        }