标签:des int data search details enc tab 表达 最小
图中:A、Value表示符号大小对应的字段,Normalization(归一化)表示将Value字段进行归一化处理。B、Classification表示根据Value字段进行分级,包含分级方式(图中为NaturalBreaks)Classes为分级数量,点击右侧Classify可对Classification进行更改设置。C、Symbol Size表示符号分级的最大最小值,右方,Template点击,可对点要素的表示符号进行设置,可设置样式、颜色、大小、初始角度。D、下方的Advanced点击可选择旋转(Rotation),设置旋转的参照字段和旋转方式(Geographic为Y向起顺时针旋转,Arithmetic为X向起逆时针旋转)。渲染示例图如下:
- public static void ArrowGraduatedRendererFlow2(IFeatureLayer pFeatureLayer, string SizeField, string RotationField)
- {
- IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;
- int classCountNum=4;
- double[] Classes = {0.0,0.5,1.0,2.0,10.0};
- try
- {
- //声明分级渲染对象
- IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();
- pClassBreaksRenderer.Field = SizeField;
- pClassBreaksRenderer.BreakCount = classCountNum;
- for (int breakIndex = 0; breakIndex < classCountNum; breakIndex++)
- {
- IRgbColor pColor = GetRGB(225, 80, 10);
- ISymbol SetSymbol = SetArrowMarkSymbol(breakIndex, pColor);
- pClassBreaksRenderer.set_Symbol(breakIndex, SetSymbol);
- pClassBreaksRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);
- }
- //设置符号旋转的渲染方式
- IRotationRenderer pRotationRenderer = (IRotationRenderer)pClassBreaksRenderer;
- pRotationRenderer.RotationField = RotationField;//设置旋转基准字段
- //pRotationRenderer.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic;//以x轴为旋转起点
- pRotationRenderer.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic;//以y轴为旋转起点
- //设置图层的渲染方式
- pGeoFeatureLayer.Renderer = (IFeatureRenderer)pClassBreaksRenderer;
- }
- catch (Exception e)
- {
- //MessageBox.Show(e.Message);
- return;
- }
- }
其中:SetArrowMarkSymbol(breakIndex, pColor)函数调用了IArrowMarkerSymbol接口,定义箭头标识。
(2)Classify分级并渲染的代码如下:
- public static void ArrowGraduatedRendererFlow(IFeatureLayer pFeatureLayer, string SizeField, string RotationField)
- {
- IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;
- ITable pTable = (ITable)pGeoFeatureLayer;
- IQueryFilter pQueryFilter = new QueryFilterClass();
- pQueryFilter.AddField("");
- ICursor pCursor = pTable.Search(pQueryFilter, true);
- //使用统计类得到最大最小值
- IDataStatistics pDataStatistics = new DataStatisticsClass();
- pDataStatistics.Cursor = pCursor;
- //设置统计字段
- pDataStatistics.Field = SizeField;
- //得到统计结果
- IStatisticsResults pStatisticsResult = pDataStatistics.Statistics;
- if (pStatisticsResult == null)
- {
- MessageBox.Show("属性值统计失败!");
- return;
- }
- int classCountNum;
- classCountNum = (int)((pStatisticsResult.Maximum - pStatisticsResult.Minimum) / 0.5) + 1;//将(流速)值按0.5m/s分级,得到分级级数
- if (classCountNum <= 0)
- {
- classCountNum = 1;
- }
- if (classCountNum >= 32)
- {
- classCountNum = 32;
- }
- double[] Classes = GetClassBreakpoints(pGeoFeatureLayer, SizeField, classCountNum);//调用函数分级
- try
- {
- //声明分级渲染对象
- IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();
- pClassBreaksRenderer.Field = SizeField;
- pClassBreaksRenderer.BreakCount = classCountNum;
- for (int breakIndex = 0; breakIndex < classCountNum; breakIndex++)
- {
- IRgbColor pColor = GetRGB(225, 80, 10);
- ISymbol SetSymbol = SetArrowMarkSymbol(breakIndex, pColor);
- pClassBreaksRenderer.set_Symbol(breakIndex, SetSymbol);
- pClassBreaksRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);
- }
- //设置符号旋转的渲染方式
- IRotationRenderer pRotationRenderer = (IRotationRenderer)pClassBreaksRenderer;
- pRotationRenderer.RotationField = RotationField;//设置旋转基准字段
- //pRotationRenderer.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic;//以x轴为旋转起点
- pRotationRenderer.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic;//以y轴为旋转起点
- //设置图层的渲染方式
- pGeoFeatureLayer.Renderer = (IFeatureRenderer)pClassBreaksRenderer;
- }
- catch (Exception e)
- {
- //MessageBox.Show(e.Message);
- return;
- }
- }
其中,分级采用等间距分级的代码如下:
- private static double[] GetClassBreakpoints(IGeoFeatureLayer pGeoFeatureLayer, string FieldName,int ClassesCount)
- {
- double[] breakPointClasses;
- if (pGeoFeatureLayer == null)
- return null;
- ITable pTable = (ITable)pGeoFeatureLayer;//ITable pTable = (ITable)pGeoFeatureLayer.FeatureClass;
- object dataValues;
- object dataFrequency;
- //从pTable的字段中得到信息给dataValues和dataFrequency两个数组
- ITableHistogram pTableHistogram = new BasicTableHistogramClass();
- pTableHistogram.Field = FieldName;
- pTableHistogram.Table = pTable;
- IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram;
- pHistogram.GetHistogram(out dataValues, out dataFrequency);
- //下面是分级方法,用于根据获得的值计算得出符合要求的数据
- IClassifyGEN pClassify;
- //根据条件计算出IClassifyGEN
- pClassify = new EqualIntervalClass();
- int tt = ClassesCount;
- pClassify.Classify(dataValues, dataFrequency, ref tt);
- //返回数组
- breakPointClasses = (double[])pClassify.ClassBreaks;
- return breakPointClasses;
- }
最终的渲染效果如下:
ArcGIS Desktop和Engine中对点要素图层Graduated Symbols渲染的实现 Rotation Symbol (转)
标签:des int data search details enc tab 表达 最小
原文地址:http://www.cnblogs.com/yuxuetaoxp/p/7298267.html